Git is a free and open-source distributed version control system that’s responsible for tracking file changes to facilitate collaborative work with others. This Cheat Sheet features the most important and commonly used Git Commands for easy reference.

Better styled PDF and Markdown formats of this Cheat Sheet are available on GitHub at the following link:

The YouTube Channels in both English (En) and French (Fr) are now accessible, feel free to subscribe by clicking here.


Configuring user information used across all repositories:

  • git config --global "[firstname lastname]": Sets a name that is identifiable for credit or ownership of change within the version history
  • git config --global "[valid-email]": Sets an email address that will be associated with each history marker

The same configs can be done for a specific project with the "--local" option that applies to the current repository only.

Basic Commands

  • git init: Initializes a new Git repository
  • git clone <url>: Clones an existing repository into a new directory
  • git add <file>: Adds changes to the staging area
  • git commit -m "<message>": Commits changes to the local repository with a message
  • git push: Pushes committed changes to a remote repository
  • git pull: Pulls changes from a remote repository
  • git fetch: Fetches changes from a remote repository

Branching and Merging

  • git branch: Lists all branches in the repository
  • git branch <name>: Creates a new branch with the given name
  • git checkout <branch>: Switches to the specified branch
  • git merge <branch>: Merges the specified branch into the current branch
  • git rebase <branch>: Rebase current branch onto specified branch

Viewing History

  • git log: Shows a log of all commits
  • git log --oneline: Shows a compact log of all commits
  • git diff <commit>..<commit>: Shows the differences between two commits
  • git blame <file>: Shows who last modified each line of a file

Undoing Changes

  • git reset <file>: Unstages changes in the given file
  • git reset <commit>: Resets the current branch to the specified commit
  • git revert <commit>: Creates a new commit that undoes the changes in the specified commit

Collaborating with Others

  • git remote add <name> <url>: Adds a new remote repository with the given name and URL
  • git remote -v: Lists all remote repositories
  • git pull --rebase: Pulls changes from a remote repository and rebases local changes on top of them
  • git push <remote> <branch>: Pushes the specified branch to the specified remote repository
Git Cheat Sheet


We have just started our journey to build a network of professionals to grow our free knowledge-sharing community that’ll give you a chance to learn interesting things about topics like cloud computing, software development, and software architectures while keeping the door open to more opportunities.

Does this speak to you? If YES, feel free to Join our Discord Server to stay in touch with the community and be part of independently organized events.


Thanks for reading this article. Like, recommend, and share if you enjoyed it. Follow us on Facebook, Twitter, and LinkedIn for more content.


About Orleando Dassi

I'm a Solutions Architect with 10 years of experience who is constantly learning while impacting the community by producing technical articles/videos, building projects, and conducting tech mentoring/coaching sessions. What describes me the most is my flexibility. Follow me on Twitter and LinkedIn.