Skip to content

Instantly share code, notes, and snippets.

@star-szr
Last active March 8, 2019 11:32
Show Gist options
  • Save star-szr/816073161aa7335af1cd to your computer and use it in GitHub Desktop.
Save star-szr/816073161aa7335af1cd to your computer and use it in GitHub Desktop.
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