Skip to content

Instantly share code, notes, and snippets.

@agirault
Last active April 4, 2025 18:19
Show Gist options
  • Save agirault/a69a7eb5862d479e68b92eef8840e5d9 to your computer and use it in GitHub Desktop.
Save agirault/a69a7eb5862d479e68b92eef8840e5d9 to your computer and use it in GitHub Desktop.
Some git aliases
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[alias]
graph = log --graph --decorate --color --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
lg = graph --first-parent
merges = lg --merges
amend = commit --amend --no-edit --signoff
amend-author = amend --author="$1"
unstage = restore --staged
fixup = "!REV=$(git rev-parse $1) && git commit --fixup $REV && GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash --autostash --rebase-merges --no-fork-point $REV^; RET=$?; while [ $RET -ne 0 ]; do git diff --diff-filter=U; if ! git status --short | grep -q ^UU; then GIT_EDITOR=true git rebase --continue; RET=$?; else git rebase --abort && git reset --soft HEAD^ && echo 'Rebase aborted: conflicts still exist' && break; fi; done #"
fix = fixup
f = fixup
edit = "!REV=$(git rev-parse $1) && GIT_SEQUENCE_EDITOR=\"sed -i '0,/^pick/s//edit/'\" git rebase -i --autostash --rebase-merges --no-fork-point $REV^ #"
reword = "!REV=$(git rev-parse $1) && GIT_SEQUENCE_EDITOR=\"sed -i '0,/^pick/s//reword/'\" git rebase -i --autostash --rebase-merges --no-fork-point $REV^ #"
branch-delete-merged = !git branch --merged | grep -Ev \"(^\\*|^\\s+master|^\\s+main$)\" | xargs git branch -d
rename = branch -m
head = rev-parse HEAD
sha = rev-parse --short=9
bblame = blame -w -C -C -C
s = status
a = add
aa = add --all
rb = rebase
rbi = rebase --interactive
rba = rebase --abort
rbc = rebase --continue
cp = cherry-pick
cpa = cherry-pick --abort
cpc = cherry-pick --continue
cps = cherry-pick --skip
cm = commit --signoff --message
p = push origin HEAD
pf = p --force
ch = checkout
chb = checkout -b
rs = reset
rsa = reset --hard
rss = reset --soft
cleanf = clean -fdq
cleani = clean -fi
d = difftool
checkout-mr = "!f() { ID=$1; REMOTE=${2:-origin}; git fetch $REMOTE pull/$ID/head:mr-$ID && git checkout mr-$ID; }; f"
sync = !r=${1:-origin} && b=$(git rev-parse --abbrev-ref HEAD) && git fetch $r $b && git rsa $r/$b
track = branch --set-upstream-to=${1:-origin}/$(git branch --show-current) $(git branch --show-current)
upstream = rev-parse --abbrev-ref $(git branch --show-current)@{upstream}
stash-search = "!f() { \n count=$(git stash list | wc -l); \n if [ \"$count\" -gt 0 ]; then \n for i in $(seq 0 $(($count - 1))); do \n git stash show $i | grep -i \"$1\" && echo \"Found in stash@{$i}\\n\"; \n done; \n else \n echo \"No stashes found\"; \n fi; \n}; f"
[commit]
verbose = true
gpgsign = true
[pull]
rebase = true
ff = only
[push]
default = current
followTags = false
autoSetupRemote = true
[branch]
autoSetupMerge = false
[rebase]
autosquash = true
autoStash = true
[core]
editor = vim
autocrlf = false
safecrlf = false
[diff]
# external = difft # use as difftool instead
tool = difftastic
[difftool]
prompt = false
[difftool "difftastic"]
cmd = difft "$LOCAL" "$REMOTE"
[pager]
difftool = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment