← Blog

Git cheat sheet

July 26, 2020

I made this cheat sheet for git terminologies and most common commands when I was learning git.

  • Repository is a directory where your project/files are stored which are used to interact with Git.

  • commit this is when you make one or more changes to a file in git.

  • branch creates a new line of development. This is mainly used to continue working without messing with the mainline of development.

  • git commit is used to commit changes to your git repo. Commit contains a message which is used to describe what changes you've made.

  • staging area this is where git will put/store files while waiting for you to commit the file containing the changes.

  • SHA this is a unique ID number that is given to each of your commits.

  • git init is used to initialize your project into a repository.

  • git clone is used to copy an existing repository to your computer.

  • git checkout takes you to a different branch in your repo.

  • git branch is used to create a new branch.

  • git checkout -b is used to create a new branch and automatically switch to it.

  • git status shows you the current status of your repo like files which are yet to be committed or the branch you are currently in.

  • git push sends all your commits to the Github/Gitlab/Bitbucket repo you have created.

  • git pull fetch all your files from your repo and integrate them with your local repo. I mostly use it to make sure everything is up to date and working correctly.

  • git add is used to add files from the working directory to the staging area.

  • git diff is used to display the differences between two versions of a file also you can see changes that are yet to be committed using this command.

  • git merge is used to combine changes from different branches together.

  • git revert is used to revert a specific commit. It is usually followed by the commit SHA to indicate which commit you want to reverse.