Professional Documents
Culture Documents
Git Cheat Sheet - 50 Git Commands You Should Know
Git Cheat Sheet - 50 Git Commands You Should Know
Forum Donate
https://www.freecodecamp.org/news/git-cheat-sheet/ 1/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
Git has many different commands you can use. And I've
found that these fifty are the ones I use the most often (and
are therefore the most helpful to remember).
https://www.freecodecamp.org/news/git-cheat-sheet/ 2/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
git config -l
Forum Donate
https://www.freecodecamp.org/news/git-cheat-sheet/ 3/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
git init
Forum Donate
git add . Learn to code — free 3,000-hour curriculum
git status
Forum
A commit message is made up of a short summary of Donate
changes, an empty line, and a full description of the changes
Learn to code — free 3,000-hour curriculum
after it.
git commit
https://www.freecodecamp.org/news/git-cheat-sheet/ 6/23
How to see your commit
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
Forum Donate
git log
git log -p
https://www.freecodecamp.org/news/git-cheat-sheet/ 7/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
Forum Donate
git show commit-id
Learn to code — free 3,000-hour curriculum
We can call diff with the --staged flag to see any staged
changes.
git diff
git diff all_checks.py
git diff --staged
https://www.freecodecamp.org/news/git-cheat-sheet/ 8/23
How to see changes using
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
Forum Donate
git add -p
git rm filename
https://www.freecodecamp.org/news/git-cheat-sheet/ 9/23
How to ignore files in Git:
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
Forum Donate
https://www.freecodecamp.org/news/git-cheat-sheet/ 10/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
https://www.freecodecamp.org/news/git-cheat-sheet/ 11/23
How to create a new branch in
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
Forum Donate
By default, you have one branch, the main branch. With this
command, you can create a new branch. Git won't switch to
it automatically – you will need to do it manually with the
next command.
https://www.freecodecamp.org/news/git-cheat-sheet/ 12/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
git branch
Forum Donate
https://www.freecodecamp.org/news/git-cheat-sheet/ 13/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
Forum
If you want to throw a merge away and start over, you can Donate
run the following command:
Learn to code — free 3,000-hour curriculum
git remote -v
https://www.freecodecamp.org/news/git-cheat-sheet/ 15/23
How to get more info about a
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
Forum Donate
git push
https://www.freecodecamp.org/news/git-cheat-sheet/ 16/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
git pull
Forum Donate
git branch -r
git fetch
https://www.freecodecamp.org/news/git-cheat-sheet/ 18/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
https://www.freecodecamp.org/news/git-cheat-sheet/ 19/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
Forum Donate
git rebase Learn
branch_name_here
to code — free 3,000-hour curriculum
https://www.freecodecamp.org/news/git-cheat-sheet/ 20/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
git push -f
Conclusion
These commands can dramatically improve your
productivity in Git. You don't have to remember them all –
that's why I have written this cheat sheet. Bookmark this
page for future reference or print it if you like.
Fabio Pacific
Hi! I am Fabio a full-stack web developer, teacher and certified
professional in IT automation with Python. I enjoy sharing
knowledge, write Python scripts and, build web apps with Laravel.
If you read this far, tweet to the author to show them you
care. Tweet a thanks
https://www.freecodecamp.org/news/git-cheat-sheet/ 21/23
5/15/23, 12:58 PM Git Cheat Sheet – 50 Git Commands You Should Know
Forum
Learn to code for free. freeCodeCamp's open source Donate
curriculum has helped more than 40,000 people get jobs as
Learn to code — free 3,000-hour curriculum
developers. Get started
ADVERTISEMENT
Our mission: to help people learn to code for free. We accomplish this by creating thousands of
videos, articles, and interactive coding lessons - all freely available to the public. We also have
thousands of freeCodeCamp study groups around the world.
Donations to freeCodeCamp go toward our education initiatives, and help pay for servers,
services, and staff.
Trending Guides
About Alumni Network Open Source Shop Support Sponsors Academic Honesty
https://www.freecodecamp.org/news/git-cheat-sheet/ 23/23