User:Stuart/Git Aliases
Jump to navigation
Jump to search
[alias]
co = checkout
st = status
up = pull --rebase
update = pull --rebase
sync = !git pull --rebase && git push
go = !git add -A && git commit && git pull --rebase && git push
removeall = !git ls-files -z --deleted | git update-index -z --remove --stdin
stashall = !git ls-files -o --exclude-standard > .gftu && git add $(cat .gftu | tr '[:blank:]' '*') && git stash
unstashall = !git stash pop && git rm --cached $(cat .gftu | tr '[:blank:]' '*') && rm .gftu
bugno = "!f() { if [ -n \"$1\" ]; then echo $1; exit 0; fi; echo $(git lastbug); }; f"
buglog = "!f() { git log --reverse --oneline --grep $(git bugno $1) | sed 's/\\(.*\\)/> \\1/g'; }; f"
buglogv = "!f() { echo \"In branch: $(git rev-parse --abbrev-ref HEAD)\"; git log --reverse --grep $(git bugno $1) | sed 's/\\(.*\\)/> \\1/g'; }; f"
findtag = describe --contains
getid = !git log --pretty=format:%H --grep
findcc = !git log --pretty=format:%H --grep
submit = !git add -A && git commit && git push
lastbug = "!git log --oneline -1 | sed \"s/[0-9a-f]* \\(Bug# \\)\\?\\(u\\?s\\?-\\?[0-9]*\\)[: \\-] .*/\\2/\""
commitbug = "!git commit -e -m \"#$(git lastbug): \""
pushbr = "!git push --set-upstream origin $(git status -bs | head -1 | sed \"s/## //\") "
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
dbver = "!f() { : git checkout; echo \"DB Ver: $(git show $1:AutomateDB/Scripts/ | sed 's/db_[a-z]*R\\(.*\\)\\.sql/\\1/' | sort -n | tail -n 1)\"; }; f"
stat= "!f() { git ls-files --exclude-standard -t -u -s -m -d $@ | sed -e 's/C.*\t/C /' ; } ; f"
tags = "!git tag | sort -t . -k1,1n -k2,2n -k3,3n"
alias = "!_git_alias() { if [ -z \"$1\" ]; then git aliases; exit 1; fi; if [ -z \"$2\" ]; then git config --global alias.$1 ; else git config --global alias.$1 \"$2\"; fi; }; _git_alias"
unalias = "!_git_unalias() { if [ -z \"$1\" ]; then echo 'Usage: git unalias <name>'; exit 1; fi; git config --global --unset alias.$1; }; _git_unalias"
find = "!f() { if [ -z \"$1\" ]; then echo 'Usage: git find <word>'; exit 1; fi; git ls-files | grep -i \"$1\"; }; f"
aliases = !git config --get-regexp alias | grep \"^alias\\.\" | sed \"s/^alias\\.\\([A-Za-z0-9-]*\\) \\(.*\\)/\\1\\t\\2/\" | awk -F\"\\t\" \"{printf \\\"%-12s %s\\n\\\", \\$1,\\$2}\" | sort | less -SEX
accept-ours = "!f() { git checkout --ours -- \"${@:-.}\"; git add -u \"${@:-.}\"; }; f"
accept-theirs = "!f() { git checkout --theirs -- \"${@:-.}\"; git add -u \"${@:-.}\"; }; f"
rmbr = "!f() { : git checkout ; if [ -z \"$1\" ]; then echo 'Usage: git rmbr <branch>'; exit 1; fi; git branch -d $1 && git push origin :$1; }; f"
rmbr-f = "!f() { : git checkout ; if [ -z \"$1\" ]; then echo 'Usage: git rmbr <branch>'; exit 1; fi; git branch -D $1 && git push origin :$1; }; f"
lslost = !git fsck --full --no-reflogs --unreachable --lost-found | grep commit | cut -d\\ -f3 | xargs -n 1 git log -n 1 \"--pretty=format:%C(red bold)%h %Creset%C(green)%ci %C(yellow)%an %Creset%s\"
bugzilla = changed-bugzilla
union = !git add -A && git commit --amend --no-edit
cp = cherry-pick -x
DISABLED-mr-qa = "!f() { : git checkout ; TARG_BR=\"master\"; if [ -n \"$1\" ]; then TARG_BR=$1; fi; URL=\"https://dev.blueprism.com/gitlab/development/qacontrol/merge_requests/new?utf8=%E2%9C%93&merge_request%5Bsource_project_id%5D=4&merge_request%5Bsource_branch%5D=$(git rev-parse --abbrev-ref HEAD)&merge_>
DISABLED-mr = "!f() { : git checkout ; TARG_BR=\"develop/v6\"; if [ -n \"$1\" ]; then TARG_BR=$1; fi; URL=\"https://dev.blueprism.com/gitlab/development/automate/merge_requests/new?utf8=%E2%9C%93&merge_request%5Bsource_project_id%5D=3&merge_request%5Bsource_branch%5D=$(git rev-parse --abbrev-ref HEAD)&merge_>
lastbug = "!git log --oneline -1 | sed -r 's/[0-9a-f]+ (Bug# )?(us-|bg-|@U|@B|@T)?([0-9]+).*/\\2\\3/'"
fresh = !git reset --hard && git clean -fxd && build
findver = "!f() { : git checkout; git tag --contains $1 | egrep \"^[0-9]+\\\\.[0-9]+\\\\.[0-9]+\\$\" | sort -V | head -n 1; }; f"
recent = !git for-each-ref --sort=-committerdate refs/heads/ --format=\"%(HEAD) %(color:red)%(objectname:short)%(color:reset) - %(align:50,left)%(color:yellow)%(refname:short)%(color:reset)%(end) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))\" | head | less -SEX
recent-remote = !git for-each-ref --sort=-committerdate refs/remotes/origin --format=\"%(HEAD) %(color:red)%(objectname:short)%(color:reset) - %(align:50,left)%(color:yellow)%(refname:short)%(color:reset)%(end) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))\" | >
tcompare = "!f() { : git checkout ; tgit compare $1 $2; }; f"