Git Cheatsheet

Git Cheatsheet

Basics of Git

What is Git?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Why is Git Important?

Git is the most commonly used version control system. Git tracks the changes you make to files, so you have a record of what has been done, and you can revert to specific versions should you ever need to.

Difference Between Git and GitHub

Git is a version control system that lets you manage and keep track of your source code history. GitHub is a cloud-based hosting service that lets you manage Git repositories.

Steps

Firstly, you will make a New Repository on GitHub and then you need to Clone it.

Cloning a Repository

git clone <repository link>

Initializing Git

git init

For Help

git help

Adding files to the Git Repository

git add .                    // for all files
git add filename.txt         // for specific file

Committing changes to the Git Repository to keep track

git commit -m "Initial commit"

Logging the changes to the Git Repository

git log
git log -n 2                    //number of commits you want to see
git log --author="Anupam"       //commit from the Author
git log --since=2022-07-01
git log --until=2022-07-24

Status of the Git Repository

git status

Git Branch

git branch <branch name>

Git Checkout

git checkout <name of branch>

Adding a Remote Repository

git remote add origin https://github.com/URL_of_your_repo

Push code to Remote Repository

git push -u origin master             //push changes to origin

Git Pull

git pull <remote>

Hope you have enjoyed🎉 learning the Basics of Git!💫
Will come up with something new next time🚀, till then Keep Learning, Keep Exploring✨