Git Cheat Sheet

A quick reference for commonly used git commands.

This cheat sheet summarizes my most commonly used git commands, and I will update it periodically.

Initialize

git config --global user.name "Name Username"
git config --global user.email [email protected]

I rarely initialize a repo locally, so I don’t need to use git init. However, keep in mind that it’s useful for initializing an existing directory as a Git repository.

Basic commands

git checkout -b <new-branch> # create new branch and switch to it, never work directly on master
git add . # add all files to next commit (stage them)
git status # check files added to commit
git commit -m "commit msg" # commit files to branch
git push # push changes to remote repository
git pull # pull changes pushhd to remote repository

Advanced commands

git revert <commit> # creates NEW commit that reverts changes introduced in specified commit
git rebase <branch> # reapplies commits on the current branch onto the tip of the specified branch

📜 This post was automatically translated from Polish using an AI language model (ChatGPT).

This site uses Google Analytics with privacy-focused settings:
• IP addresses are anonymized
• Do Not Track signals are honored
• Cookies are used to track sessions

This work is licensed under CC BY-NC-SA 4.0 CC BY NC SA


Built with Hugo
Theme Stack designed by Jimmy