Last active
April 17, 2025 08:30
-
-
Save neocotic/f06c8161a43f0c8b109c0033e83c5228 to your computer and use it in GitHub Desktop.
Git Config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
co = checkout | |
cob = "!f() { git checkout -B $1; }; f" | |
br = branch | |
ci = commit | |
sh = stash | |
st = status | |
unstage = reset HEAD -- | |
last = log -1 HEAD | |
undo = checkout -- . | |
main = checkout main | |
mast = checkout master | |
dev = checkout develop | |
bug = "!f() { git checkout -B \"bugfix/$1\"; }; f" | |
feat = "!f() { git checkout -B \"feature/$1\"; }; f" | |
hot = "!f() { git checkout -B \"hotfix/$1\"; }; f" | |
rel = "!f() { git checkout -B \"release/$1\"; }; f" | |
tidy = "!f() { git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done }; f" | |
pt = "!f() { git pull && git tidy; }; f" | |
mainpt = "!f() { git checkout main && git pull && git tidy; }; f" | |
mastpt = "!f() { git checkout master && git pull && git tidy; }; f" | |
devpt = "!f() { git checkout develop && git pull && git tidy; }; f" | |
# GitHub | |
pr = "!f() { git fetch -fu ${2:-$(git remote | grep ^upstream || echo origin)} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f" | |
tidypr = "!f() { git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref; do branch=${ref#refs/heads/}; git branch -D $branch; done }; f" | |
# GitLab | |
mr = "!f() { git fetch -fu ${2:-$(git remote | grep ^upstream || echo origin)} refs/merge-requests/$1/head:mr/$1 && git checkout mr/$1; }; f" | |
tidymr = "!f() { git for-each-ref refs/heads/mr/* --format='%(refname)' | while read ref; do branch=${ref#refs/heads/}; git branch -D $branch; done }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment