Git Cheat Sheet
Git Cheat Sheet
GitHub CheatSheet
GIT
Git is a version control system that is used for tracking
changes in computer files and coordinating work on those
files among multiple people. It is a distributed version
control system, which means that it allows multiple users to
work on the same files simultaneously and keeps track of
changes made to the files by each user. Git is widely used
in software development and has become a standard tool
for collaborating on code.
git init
initialize an existing directory as a Git repository.
git status
show modified files in working directory, staged for your next
commit.
3|Page
git add [file]
add a file as it looks now to your next commit (stage).
git diff
diff of what is changed but not staged.
git branch
list your branches, a* will appear next to the currently active
branch.
git checkout
switch to another branch and check it out into your working
directory.
git log
show all commits in the current branch’s history.
4|Page
INSPECT & COMPARE
Examining logs, diffs and object information.
git log
show the commit history for the currently active branch.
git rm [file]
delete the file from project and stage the removal for commit.
5|Page
IGNORING PATTERNS
Preventing unintentional staging or committing of files.
logs/
*.notes
pattern*/
Save a file with desired patterns as .gitignore with either direct
string matches or wildcard globs.
git pull
fetch and merge any commits from the tracking remote branch.
6|Page
REWRITE HISTORY
Rewriting branches, updating commits and clearing history.
TEMPORARY COMMITS
Temporarily store modified, tracked files in order to change
branches.
git stash
Save modified and staged changes.
7|Page