Last active
December 12, 2023 17:44
-
-
Save Palisand/9a0929974dc0c6f5eed71a26e2a6d5f8 to your computer and use it in GitHub Desktop.
Git aliases
This file contains 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" | |
ad = "!f() { git add -u && git st; }; f" | |
amend = commit --amend | |
br = rev-parse --abbrev-ref HEAD | |
comm = "!f() { git commit -m \"$1\"; }; f" | |
commend = "!f() { git commit --amend --no-edit && echo && git st; }; 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" | |
ls = "!f() { git log --oneline -${1-1}; }; f" | |
la = "!f() { git log -${1-1}; }; f" | |
please = push --force-with-lease | |
publish = "!git push --set-upstream origin $(git br)" | |
st = status --short --branch | |
sls = stash list | |
sshow = "!f() { git stash show stash@{${1-0}}; }; f" | |
sshop = "!f() { git stash show -p stash@{${1-0}}; }; f" | |
sdrop = "!f() { git stash drop stash@{${1-0}}; }; f" | |
spop = "!f() { git stash pop stash@{${1-0}}; }; 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" | |
# open PR | |
pr = "!f() { \ | |
open \"$(git ls-remote --get-url $(git config --get branch.$(git rev-parse --abbrev-ref HEAD).remote) \ | |
| sed 's|git@github.com:\\(.*\\)$|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|git@github.com:\\(.*\\)$|https://github.com/\\1|' \ | |
| sed 's|\\.git$||'; \ | |
)\"; \ | |
}; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment