Skip to content

Instantly share code, notes, and snippets.

@trajano
Last active May 16, 2021 09:48
Show Gist options
  • Save trajano/30ecee958a11f3d296612018272c456d to your computer and use it in GitHub Desktop.
Save trajano/30ecee958a11f3d296612018272c456d to your computer and use it in GitHub Desktop.
git aliases
#!/bin/sh
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.pu '!git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
git config --global alias.puf '!git push --force --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
git config --global alias.r '!git fp && (GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash origin/HEAD || GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash origin/master)'
git config --global alias.fr '!git fp && git pull --rebase origin HEAD'
git config --global alias.fp 'fetch --prune'
git config --global alias.ac '!git add -A && git commit'
git config --global alias.amend 'commit --amend -a --reuse-message=HEAD'
git config --global alias.remaster 'rebase -i origin/HEAD'
git config --global alias.rh 'rehead'
git config --global alias.rehead '!git fetch && git checkout origin/HEAD -b'
#git config --global --get-regexp alias.* | sed 's/\(alias\.[^ ]\+\) \(.*\)/git config --global \1 '\"'\2'\"'/'"
git config --global --get-regexp alias.* | sed 's/!/\\!/g' | sed 's/\(alias\.[^ ]\+\) \(.*\)/git config --global \1 '\"'\2'\"'/'
git config --global alias.aliases "!git config --global --get-regexp alias.* | sed 's/\(alias\.[^ ]\+\) \(.*\)/git config --global \1 '\"'\2'\"'/'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment