Instantly share code, notes, and snippets.

Embed
What would you like to do?
[alias]
### Informational aliases ###
# shows all origin branches
origin = remote show origin
# shows current branch
current = symbolic-ref --short HEAD
# updates refs and shows status
s = !git remote -v update && git status
# compare with local branch before push
bp = !brnch=$(git current) && git diff --stat --cached origin/$brnch
# shows pretty logs (:q to quit vim)
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
# shows not merged branches
nm = log --no-merges develop..
### Branch aliases ###
# adds tracking to current branch
track = !brnch=$(git current) && git branch --set-upstream-to=origin/$brnch $brnch
# gets remote branch: git chk develop. "|| exit" - trick to ignore branch name (to remove leading space)
get = !git checkout --track origin/$@ || exit
# checkout existing local branch: git chk develop. "|| exit" - trick to ignore branch name (to remove leading space)
chk = checkout
# creates new branch: git new new-branch-name
new = checkout -b
### Remote aliases ###
# pulls changes from remote (if branch is not tracked use 'track' alias before this command)
up = pull
# pushes changes with tracking
p = push -u origin HEAD
### Commit aliases ###
# commit with specified message like: "Test message" (double quotes). NB: if you have PuntoSwitcher installed, add your console to exceptions
com = !git add -A && git commit -m
# commit without message (opens vim or text editor from core.editor)
c = !git add -A && git commit
# commit without message (opens vim or text editor from core.editor) and push immediately. NB: use with caution - you can push something wrong without review.
cp = !git c $@ && git p
### Merge aliases ###
# type "git mt" to merge without backups (depends on [mergetool "cmd"] block). NB: works in bash only! For cmd/clink use git mergetool --tool=cmd
mt = !git mergetool --tool=cmd
# launches UI for diff
dt = !git difftool
# merge current branch into develop (no fast-forward)
mdev = !brnch=$(git current) && (echo "develop" | grep -q "$brnch") && echo "cannot merge from $brnch to develop" || git chk develop && git merge --no-ff $brnch
# merge develop into current branch (no fast-forward)
mcur = !git merge --no-ff develop
### Current work aliases ### see also http://haacked.com/archive/2014/07/28/github-flow-aliases/
# saves all files including untracked
save = !git add -A && git commit -m "SAVEPOINT"
# saves all tracked files
wip = commit -am "WIP"
# reset one of previous commit to continue work // keep all changes in working directory
undo = reset HEAD~1 --mixed
# amend previous commit to change message, can be restored with: git reset --soft HEAD@{1}
amend = commit -a --amend
### Advanced aliases ###
# discard all changes for tracked file
disfile = checkout --
# discard all unstaged changes for tracked files, to remove untracked files use "git fclean
discard = checkout -- .
# remove all untracked files with directories
fclean = clean -f -d
# saves changes before reset, to restore: git reflog, reset <hash from reflog>, amend, pull, push
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
# finds out which branch contains a change with specified hash: git findhash d0f2338
findhash = branch --contains
# shows pretty logs (:q to quit vim)
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
[credential]
helper = manager
@matolg

This comment has been minimized.

Show comment
Hide comment
@matolg

matolg Feb 8, 2018

I see lg mentioned twice )

matolg commented Feb 8, 2018

I see lg mentioned twice )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment