Skip to content

Instantly share code, notes, and snippets.

@guilhermebkel
Last active October 5, 2020 20:06
Show Gist options
  • Save guilhermebkel/6e39189a5319e99da64de54dcd906eba to your computer and use it in GitHub Desktop.
Save guilhermebkel/6e39189a5319e99da64de54dcd906eba to your computer and use it in GitHub Desktop.
Git Configuration
[user]
name = Guilherme Mota
email = guilhermebromonschenkel@gmail.com
[core]
editor = code --wait
[push]
followTags = true
[alias]
# Shows a status of the current modifications you did
s = !git status -s
# Adds the modified files and start a git commit after it. Ex: git c "chore(*): remove useless files"
c = !git add --all && git commit -m
# Shows all the git formatted log
l = !git log --pretty=format:'%C(blue)%h%C(red)%d %C(white)%s - %C(cyan)%cn, %C(green)%cr'
# It is like a git pull but more powerful
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
# Alias of git checkout -b. Ex: git cob feat/getFiles
cob = !git checkout -b
# Resets to the last commit
undo = !git reset HEAD~1 --mixed
# Modifies the last commit
amend = !git commit -a --amend
# Like a git reset --hard but keeping a checkpoint on the modifications you did in case you need it later
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
# Cleans all merged branchs based on the supplied one (uses master if nothing no branch given). Ex: bclean feat/getFiles
bclean = "!f() { git checkout ${1-master} && git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs git branch -d; }; f"
# Goes to the default branch, make it up to the remote one and delete all merged branchs.
bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master}; }; f"
# Adds last edits to the last commit
mix = !git commit --amend --no-edit
# Reverts a reverted/merged branch into a new one to keep the old work you have done before the revert. Ex: remake reverted-branch fix/some-bug
remake = "!f() { git checkout $1 && git revert $1 && git checkout -b $2; }; f"
# Commands to open and edit the git config in VSCode
git config --global core.editor code
git config --global --edit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment