Last active
December 5, 2016 18:47
-
-
Save dotproto/f6918121c77a9ffb5921ad0c1117de9f 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
[alias] | |
# List all aliases | |
aliases = ! git config --get-regexp ^alias\\. | sed -e s/^alias\\.// -e s/\\ /\\ =\\ / | |
# Edit your git configuration (cfg) | |
cfg = config -e --global | |
# Show the (last) commit | |
last = log -1 | |
# last = show HEAD | |
# Retrieve the (SHA) hash of a given commitish | |
sha = !sh -c 'git rev-parse ${1-`echo HEAD`}' - | |
# Find a branch that matches the user-supplied partial name | |
# | |
# 1. `git branch --list` - List the current branches | |
# 2. `cut -c 3-` - Cut off the first 3 characters to remove the asterist on the current branch | |
# 3. `grep -i $1` - Find all branches that match the user-provided name (case insensitive) | |
# 4. `head -1` - Get the first result | |
find-branch = !sh -c 'git branch --list | cut -c 3- | grep -i $1 | head -1' - | |
# Checkout (chk) branches using a partial branch name | |
# | |
# 0. `!sh -c '...' -` - Execute the following shell command & pass any additonal parameters as $0, etc. | |
# 1. `git checkout $(...)` - Check out the end result of the following commands ... | |
# 2. `git branch-list $1` - Defer to the branch-list alias to look up the specified name | |
chk = !sh -c 'git checkout $(git branch-list $1)' - | |
# Merge a successive branch (by partial name) into the current branch | |
succeed = "!f() { BRANCH=$(git find-branch $1); if [ ! -z "$BRANCH" ]; then git merge --no-ff --no-edit $BRANCH; fi; }; f" | |
# Shorthand to create a (squash) or (fixup) commit | |
squash = commit --squash=HEAD | |
fixup = commit --fixup=HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment