Last active
February 9, 2025 20:09
-
-
Save Palisand/9a0929974dc0c6f5eed71a26e2a6d5f8 to your computer and use it in GitHub Desktop.
Git aliases
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] | |
# https://hackernoon.com/lesser-known-git-commands-151a1918a60 | |
# https://gist.github.com/robmiller/6018582 | |
# https://www.atlassian.com/blog/git/advanced-git-aliases | |
# https://bitbucket.org/durdn/cfg/src/master/.gitconfig?at=master | |
# https://softwaredoug.com/blog/2022/11/09/idiot-proof-git-aliases.html | |
# template: "!f() { git ; }; f" | |
st = status --short --branch | |
ls = "!f() { git log --oneline -${1-1}; }; f" | |
la = "!f() { git log -${1-1}; }; f" | |
br = rev-parse --abbrev-ref HEAD | |
ad = "!f() { git add -u && git st; }; f" | |
com = "!f() { git commit -m \"$1\"; }; f" | |
comend = "!f() { git commit --amend --no-edit && echo && git st; }; f" | |
please = push --force-with-lease | |
publish = "!git push --set-upstream origin $(git br)" | |
# stash | |
sl = stash list | |
ss = "!f() { git stash show -p stash@{${1-0}}; }; f" | |
spop = "!f() { git stash pop stash@{${1-0}}; }; f" | |
sdrop = "!f() { git stash drop stash@{${1-0}}; }; f" | |
# open PR | |
pr = "!f() { \ | |
open \"$(git ls-remote --get-url $(git config --get branch.$(git rev-parse --abbrev-ref HEAD).remote) \ | |
| sed 's|[email protected]:\\(.*\\)$|https://github.com/\\1|' \ | |
| sed 's|\\.git$||'; \ | |
)/compare/$(\ | |
git config --get branch.$(git rev-parse --abbrev-ref HEAD).merge | cut -d '/' -f 3- \ | |
)?expand=1\"; \ | |
}; f" | |
# open repo | |
hub = "!f() { \ | |
open \"$(git ls-remote --get-url \ | |
| sed 's|[email protected]:\\(.*\\)$|https://github.com/\\1|' \ | |
| sed 's|\\.git$||'; \ | |
)\"; \ | |
}; f" | |
# cpr = "!f() { git checkout ${1-FAIL} && git pull && git checkout -; }; f" | |
# msync = "!f() { git cpr $1 && git merge $1; }; f" | |
# rsync = "!f() { git cpr $1 && git rebase $1; }; f" | |
# inserts = "!f() { git diff --shortstat staging..`git branch --show-current` | awk '{split($0,a,\" \"); print a[4]}'; }; f" | |
# recheck = "!f() { git branch -D $1 && git checkout -b $1; }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment