Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick branch creation and patch applying
# Create or go to branch.
git go <name of branch>
# Apply the patch, commit with a commit message of "p".
cape && gcm p
[alias]
# Switch to a branch, creating it if necessary
go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f"
alias gcm="git commit -m"
# Patch shortcuts
#
# Copy a patch URL to the clipboard, then run one of these commands to download
# the patch and apply it. Hat tip to @chrisjlee for making me reconsider curl.
#
# Apply
alias cap='curl `pbpaste` | git apply -v'
# Apply and stage
alias cape='curl `pbpaste` | git apply -v --index'
# Apply with `patch`
alias capp='curl `pbpaste` | patch -p1'
# Reverse apply
alias carp='curl `pbpaste` | git apply -Rv'
# Reverse apply and stage
alias carpe='curl `pbpaste` | git apply -Rv --index'
# Verify patch
alias cav='curl `pbpaste` | git apply -v --check'
# Verify patch with `patch`
alias capv='curl `pbpaste` | patch -p1 --dry-run'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.