Skip to content

Instantly share code, notes, and snippets.

@gidgid
gidgid / .gitconfig
Last active October 17, 2020 12:48
All Git aliases in one gist
[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"
@gidgid
gidgid / bash
Last active October 13, 2019 14:20
Show how to use git checkout by regex
# imagine you're on master
# and you want to checkout to branch some-very-long-branch-name
$ g cor long
# using a unique part of the branch name makes it much easier to checkout
@gidgid
gidgid / .gitconfig
Last active August 6, 2024 05:17
Git aliases with FZF
[alias]
# more aliases here
## "checkout fzf" checkout with fzf
cof = "!checkout_fzf() { git branch | fzf | xargs git checkout; }; checkout_fzf"
## "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"
@gidgid
gidgid / .gitconfig
Last active October 13, 2019 13:42
Showing Git checkout by regex
[alias]
# checkouts
## "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"
@gidgid
gidgid / .gitconfig
Last active November 7, 2019 10:23
More aliases
[alias]
# 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
@gidgid
gidgid / shell
Last active October 12, 2019 20:15
Using Gitconfig basic aliases
# add all files except untracked
$ git au
# add all files
$ git aa
# you can use it to add all the contents of a specific directory
$ git aa <dirname>
# add patch
$ git ap <filename>
# checkout & create a new branch
$ git cob <new-branch-name>
@gidgid
gidgid / .gitconfig
Created October 10, 2019 19:57
Shows my adds and checkouts in Gitconfig
[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
# Checkouts