Show Menu
Cheatography

Git Help Cheat Sheet (DRAFT) by

My git cheat sheet for my common commands

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Global Config

[alias]
        co = switch
        hist = log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short
        fixup = "!git log -n 50 --pretty=format:'%h %s' --no-merges | fzf | cut -c -7 | xargs -o git commit --fixup"
[core]
        editor = vim
        excludesfile = ~/.gitignore_global
[rebase]
        autoSquash = true
[diff "ansible-vault"]
        textconv = ansible-vault view
[commit]
        gpgsign = true
[gpg]
        program = /usr/bin/gpg
[credential "https://github.com"]
        helper =
        helper = !/usr/bin/gh auth git-credential
[credential "https://gist.github.com"]
        helper =
        helper = !/usr/bin/gh auth git-credential

Rebase

Rebase with main
git rebase -i origin­/main
continue rebase
git rebase --continue
Skip empty commit
git cherry­-pick --skip
p, pick
use commit
r, reword
edit commit message
e, edit
amend commit
s, squash
meld into previous commit
f, fixup
like squash, but discard this commit message
x, exec
run command
b, break
stop here
d, drop
remove commit
l, label <la­bel>
label current HEAD with a name
t, reset <la­bel>
reset HEAD to a label
m, merge -c <co­mmi­t]>
create a merge commit using reworded commit
 

Patching

Stash
git stash -p
Add file
git add -p <fi­le>
y
stage this hunk
n
do not stage this hunk
q
quite; do not stage this nor any remaining
a
stage this hunk and all later
d
do not stage this hunk or any later
g
select a hunk to go to
/
search for hunk matching regex
j
leave undecided; see next undecided
J
leave undecided; see next hunk
k
leave undecided; see previous undecided
K
leave undecided; see previous hunk
s
split hunk
e
manually edit hunk
?
print help