You are on page 1of 1

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​/br​anc​hname git log --stat
git log --name​-status
Workflow git log --follow --pret​ty=​for​mat​:'%an (%ae)'
file.c | sort | uniq
git fetch
git worktree
git checkout featur​e/f​eat​ure-x
# which commit came this branch from?
git commit -m "​[Fe​ature] feature x implem​ent​‐
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 --form​at=​"%ai %ar by %an" $branch | head -n
git checkout featur​e/f​eat​ure-x
1` \\t$br​anch; done | sort -r
git rebase develop
# Amend a (non-p​ushed) commit
git add fixed files list
git commit --amend --no-edit
git rebase --continue
# clear local tags
git checkout develop
git fetch --prune origin "​+re​fs/​tags/
:refs/​‐
git merge --no-ff featur​e/f​eat​ure-x
tags/"
git push
git remote show origin
git branch -D featur​e/f​eat​ure-x
git checkout --track origin​/br​anc​hname
git push origin :featu​re/​fea​ture-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 --pret​ty=​for​mat​:'%an (%ae)'
# compares file from current branch to master
file.c | sort | uniq
git diff HEAD..m​aster 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/

You might also like