Skip to content

Instantly share code, notes, and snippets.

@mateusreis
Forked from codexico/.gitconfig
Last active August 29, 2015 14:13
Show Gist options
  • Save mateusreis/863cee2eb3489c30ec29 to your computer and use it in GitHub Desktop.
Save mateusreis/863cee2eb3489c30ec29 to your computer and use it in GitHub Desktop.
# ~/.gitconfig
# https://gist.github.com/codexico/2a34c0d599f3af93b46f
[alias]
# Retorna todos os alias desta lista
alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t\\2/' | sort;
# Retorna o caminho do repositório
url = remote -v;
##########
# logs
##########
# Retorna os dados do último commit
last = log -1 HEAD;
# View the SHA, description, and history graph of the latest 20 commits
l = log --abbrev-commit --pretty=oneline -n 20 --graph
# Retorna o último usuário que commitou
who = shortlog -sne;
# Retorna as datas e comentários dos últimos commits
history = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
# Exibe a última tag
lasttag = describe --tags --abbrev=0;
# Lista dos commits do user do git
mylog = !git log --author="$(git config user.name)" --pretty=format:"%h - %an, %ar : %s"
##########
# status
##########
# View the current working tree status using the short format
s = status -s
# Diff
d = diff --patch-with-stat
##########
# commits
##########
# lazy alias
c = commit;
cmt = commit -am
# Commit all changes
ca = !git add . && git add -u && git commit -a
# unchanged file to prevent commits
unchanged = git update-index --assume-unchanged
##########
# pull, push
##########
# pull
get = !git pull origin $(git rev-parse --abbrev-ref HEAD);
# push
post = !git push origin $(git rev-parse --abbrev-ref HEAD);
# pull and push
update = "!f() { BRANCH=$(git rev-parse --abbrev-ref HEAD); git s && git pull origin $BRANCH && git push origin $BRANCH; }; f"
##########
# deploys
##########
# develop
dev-deploy = !git pull origin develop && git push origin develop && say -v "hysterical" "git git giiiit"
# develop and hml
hml-deploy = !git pull origin develop && git push origin develop && git checkout hml && git pull origin hml && git merge develop && git push origin hml && git checkout develop
# branch-deploy
branch-deploy = "!f() { BRANCH=$(git rev-parse --abbrev-ref HEAD); git pull origin $BRANCH && git push origin $BRANCH && git checkout develop && git pull origin develop && git merge $BRANCH && git push origin develop && git checkout hml && git pull origin hml && git merge develop && git push origin hml && git checkout $BRANCH && say -v "cellos" "Finished"; }; f"
##########
# branchs
##########
# lazy alias
b = branch
co = checkout;
# create branch local and remote
create = "!f() { git checkout -B $1 && git push origin $1; }; f";
# deleta branch
rmbranch = update-ref -d HEAD
# Retorna todos os branchs atualizados
branchs = !git fetch --all && git fetch -p && git branch -a;
# Faz a troca de branch e atualiza o de destino
change = "!f() { git checkout $1 && git pull origin $1; }; f";
# deixa somente branchs que exitem remoto
clearbranchs = !git branch -a | grep -v 'origin' | xargs git branch -D
##########
# undo
##########
# Undo a `git push`
undopush = push -f origin HEAD^:master
# Undo merge
undomerge = reset --hard HEAD@{1}
# Desfaz todas as alterações que ainda não foram commitadas
undo = reset --hard;
# Desfaz o último commit, o tira do stage; Você pode passar um arquivo ou uma lista (separada por espaço) como argumento
unstage = reset HEAD -- #file;
#===========================================
# Não testei ainda mas parecem práticos:
#===========================================
# Faz o merge mantendo a minha versão
ours = "!f() { git checkout --ours $@ && git add $@; }; f";
# Faz o merge mantendo a versão do caboclo
theirs = "!f() { git checkout --theirs $@ && git add $@; }; f";
#===========================================
# Alias que acho perigosos e já vi por aí e não recomendo o uso:
#===========================================
# a add .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment