Last active
December 12, 2015 06:39
-
-
Save igorescobar/4730705 to your computer and use it in GitHub Desktop.
Aliases You Can't Live Without
This file contains hidden or 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
co = checkout | |
# ds: it is always best practice to review the changes you're going to commit before making the actual commit. This allows you to catch typos, accidental inclusion of sensitive data and grouping code into logical groups. Stage your changes and then use git ds to see the diff of those changes. | |
ds = diff --staged | |
#st: you should be pretty familiar with the verbose output of git status. At some point you'll want to skip all the formality and get down to business. This alias shows the short form of status and includes the branch details. | |
st = status -sb | |
#amend: did you forget to include a file with your last commit, or maybe you had one tweak you needed to make? Amend the staged changes to your last commit. | |
amend = commit --amend -C HEAD | |
#undo: sometimes, amending your last commit isn't enough and you'll need to undo it instead. This alias will step back one commit and leave the changes from that commit staged. Now you can make additional changes, or recommit with a new message. | |
undo = reset --soft HEAD^ | |
#ls: working on a codebase with a group of developers means trying to keep up with what people are working on. This alias will provide a one line git log including date and committer name. | |
ls = log --pretty=format:\"%C(yellow)%h %C(blue)%ad%C(red)%d %C(reset)%s%C(green) [%cn]\" --decorate --date=short | |
#standup: this alias is great for reviewing what you worked on yesterday for any type of daily standup, or just to refresh your memory in the morning. | |
standup = log --since '1 day ago' --oneline --author <YOUREMAIL> | |
#graph: a complex git history can be difficult to review in a straight line. Using the graph flag shows you how and when commits were added to the current branch. | |
graph = log --graph --pretty=format':%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset' | |
# show modified files in last commit: | |
dl = "!git ll -1" | |
# Show a diff last commit: | |
dlc = diff --cached HEAD^ | |
# Show content (full diff) of a commit given a revision: | |
dr = "!f() { git diff "$1"^.."$1"; }; f" | |
lc = "!f() { git ll "$1"^.."$1"; }; f" | |
# Find a file path in codebase: | |
f = "!git ls-files | grep -i" | |
diffr = "!f() { git diff "$1"^.."$1"; }; f" | |
# Search/grep your entire codebase for a string: | |
grep = grep -Ii | |
# Grep from root folder: | |
gra = "!f() { A=$(pwd) && TOPLEVEL=$(git rev-parse --show-toplevel) && cd $TOPLEVEL && git grep --full-name -In $1 | xargs -I{} echo $TOPLEVEL/{} && cd $A; }; f" | |
gr = grep -Ii | |
# Rename [branch] to done-[branch] | |
done = "!f() { git branch | grep "$1" | cut -c 3- | grep -v done | xargs -I{} git branch -m {} done-{}; }; f" | |
cp = cherry-pick | |
st = status -s | |
cl = clone | |
ci = commit | |
co = checkout | |
br = branch | |
diff = diff --word-diff | |
dc = diff --cached | |
r = reset | |
r1 = reset HEAD^ | |
r2 = reset HEAD^^ | |
rh = reset --hard | |
rh1 = reset HEAD^ --hard | |
rh2 = reset HEAD^^ --hard | |
# shows list of files that have a merge conflict | |
conflicts = diff --name-only --diff-filter=U | |
changes = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | |
# unstages a file. use like 'git unstage filename' | |
unstage = reset HEAD -- | |
# resets all uncomitted changes and files | |
abort = reset --hard HEAD | |
# shows diff only for files staged to commit | |
new = diff --cached | |
# shows only changes to files in current directory | |
here = status . | |
# undo last commit | |
undo = reset HEAD~1 | |
# change last commit message | |
recommit = commit --amend | |
# pair programming | |
pair = !git config user.name \"Igor & $1\" | |
unpair = config --unset-all user.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment