Created
April 26, 2016 08:28
-
-
Save iand/23af1a408d7eec29117fa260a397f02d to your computer and use it in GitHub Desktop.
Git Aliases
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
# Show modified files in last commit: | |
dl = "!git ll -1" | |
# Show a diff last commit: | |
dlc = diff --cached HEAD^ | |
# List oneline commits showing relative dates: | |
ld = log --pretty=format:"%C(yellow)%h\\ %Cred%d\\ %Creset%s\\ %C(green)(%ad)%Cblue\\ [%cn]" --decorate --date=relative | |
# List oneline commits showing dates | |
lds = log --pretty=format:"%C(yellow)%h\\ %Cred%d\\ %Creset%s\\ %C(green)(%ad)%Cblue\\ [%cn]" --decorate --date=short | |
# List commits showing changed files | |
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat | |
# List commits in short form, with colors and branch/tag annotations. | |
ls = log --pretty=format:"%C(yellow)%h\\ %Cred%d\\ %Creset%s\\ %C(green)(%ad)%Cblue\\ [%cn]" --decorate --date=relative | |
# List all git aliases | |
la = "!git config -l | grep alias | cut -c 7-" | |
# Suggestions from http://gggritso.com/human-git-aliases | |
branches = branch -a | |
tags = tag | |
stashes = stash list | |
# List all changes by me since yesterday | |
yesterday = log --since yesterday --author ian | |
# Brief status | |
st = status -sb | |
# Commit all changes with a message | |
c = commit -am | |
# Add all files | |
a = add -A | |
## Just a shorter alias | |
co = checkout | |
# undo the last commit | |
undo = reset --soft HEAD~1 | |
# Edit the last commit | |
amend = commit --amend | |
# Discard modifications made to a file | |
discard = checkout -- | |
# Unstage a file | |
unstage = reset -q HEAD -- | |
# Start a new feature branch by updating master then create a new branch then push it to origin | |
new = "!f() { git checkout master && git fetch origin && git merge --ff origin/master && git checkout -b $1 master && git push -u origin $1; }; f" | |
# Merge from master | |
up = !git fetch origin && git rebase -p origin/master | |
# Interactive rebase to master | |
ir = !git rebase -i origin/master | |
# Commit changes to origin | |
done = !git fetch origin && git rebase -p origin/master && git push | |
# remove a branch both locally and remotely when it is no longer needed | |
rmb = "!f() { git branch -D $1 && git push origin :$1; }; f" | |
# list all local merged branches that have been deleted on remote | |
lsm = "!f() { git branch --merged | grep -v \"\\*\"; }; f" | |
# remove all local merged branches that have been deleted on remote | |
rmm = "!f() { git branch --merged | grep -v \"\\*\" | xargs -n 1 git branch -d; }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment