GIT Cheat Sheet
by Alexandre Hausen (alexandreceolin) via cheatography.com/24507/cs/9235/
Example Useful Commands
git fetch origin --prune git log --oneline
git checkout --track origin/branchname git log --stat
git log --name-status
Workflow git log --follow --pretty=format:'%an (%ae)'
file.c | sort | uniq
git fetch
git worktree
git checkout feature/feature-x
# which commit came this branch from?
git commit -m "[Feature] feature x implement‐
git merge-base new_branch old_branch
ed"
# merged branches not deleted
git push
for branch in `git branch -r --merged
git checkout develop
origin/master | grep -v HEAD`;do echo -e `git
git pull
show --format="%ai %ar by %an" $branch | head -n
git checkout feature/feature-x
1` \\t$branch; done | sort -r
git rebase develop
# Amend a (non-pushed) commit
git add fixed files list
git commit --amend --no-edit
git rebase --continue
# clear local tags
git checkout develop
git fetch --prune origin "+refs/tags/
:refs/‐
git merge --no-ff feature/feature-x
tags/"
git push
git remote show origin
git branch -D feature/feature-x
git checkout --track origin/branchname
git push origin :feature/feature-x
Log
diff
git log --oneline
git diff --staged
git log --stat
# what has changed in this file from last commit
git log --name-status
git diff HEAD~1..HEAD file.txt
git log --follow --pretty=format:'%an (%ae)'
# compares file from current branch to master
file.c | sort | uniq
git diff HEAD..master file.txt
# compares the stash against the commit it is
based on
git diff stash@{0}^!
# see the most recent stash
git stash show -p
git stash show -p stash@{0}
By Alexandre Hausen Not published yet. Sponsored by CrosswordCheats.com
(alexandreceolin) Last updated 6th March, 2023. Learn to solve cryptic crosswords!
Page 1 of 1. http://crosswordcheats.com
cheatography.com/alexandreceolin/