Last active
October 17, 2020 12:48
-
-
Save gidgid/f25f1ec32fe0bc1b373ac4344ec4109e to your computer and use it in GitHub Desktop.
All Git aliases in one gist
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] | |
# Adding files | |
## "add untracked" - no untracked files | |
au = add -u | |
## "add all" - add everything. https://stackoverflow.com/questions/572549/difference-between-git-add-a-and-git-add | |
aa = add -A | |
## "add patch" - choose what to add | |
ap = add -p | |
## "add fzf" add multiple files with fzf | |
aaf = "!add_fzf() { git status -s | awk '{print $2}' | fzf -m | xargs git add; }; add_fzf" | |
## "add files and commit" add files with fzf and then immediately commit | |
afc = "!add_files_and_commit() { git status -s | awk '{print $2}' | fzf -m | xargs git add && git commit --verbose; }; add_files_and_commit" | |
aumned = !git add -u && git commit --amend | |
# Checkouts | |
co = checkout | |
## "checkout branch" - checkout to a newly created branch (git branch <name>; git checkout <name>) | |
cob = checkout -b | |
## "checkout patch" - decide what to checkout | |
cop = checkout -p | |
## "checkout regex" - more or less checkout branches by regex | |
cor = "!checkout_by_regex() { git checkout $(git branch | grep -e \"$1\" | head -n1); }; checkout_by_regex" | |
## "checkout fzf" checkout with fzf | |
cof = "!checkout_fzf() { git branch | fzf | xargs git checkout; }; checkout_fzf" | |
# commits | |
## show me my diff while writing the commit message | |
ct = commit --verbose | |
## "commit add" add all files then commit | |
cta = commit -a --verbose | |
## amend is slightly long but it felt natural this way | |
amend = commit --verbose --amend | |
## you can combine actions like this: | |
## "add amend" - first add, then amend | |
aamend = !git add -A && git commit --amend | |
## "add untracked amend" - add files except for untracked, then amend | |
aumend = !git add -A && git commit --amend | |
# diffs | |
## plain old diff | |
df = diff | |
## "diff working with stage" - diff with the staging area | |
dfws = diff --staged | |
## "diff stage with last commit" | |
dfsc = diff --staged HEAD | |
## "diff current with last commit" | |
dflc = diff HEAD^ HEAD | |
## "diff names" - show diff only with file names | |
dfnames = diff --name-only | |
# logs | |
## "log pretty" - dont worry too much about the formatting | |
lgp = log --oneline --graph --decorate --pretty=format:\"%C(auto)%d%C(reset) %s %C(magenta)(%ar)%C(reset) %C(cyan)%h%C(reset) %C(red)[%cn]%C(reset)\" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment