Skip to content

Instantly share code, notes, and snippets.

@rolandwalker
Created October 24, 2014 12:21
Show Gist options
  • Select an option

  • Save rolandwalker/0ac2984e3765b8fd413e to your computer and use it in GitHub Desktop.

Select an option

Save rolandwalker/0ac2984e3765b8fd413e to your computer and use it in GitHub Desktop.
gitconfig PR aliases
[alias]
# change default of "upstream" if needed
pr = "!f() { \
local number=\"${1:-}\"; \
number=\"${number#\\#}\"; \
if test -z \"$number\" || test \"$#\" -gt 2; then \
echo 'syntax: git pr <integer> [<remote-to-fetch>]'; \
exit 1; \
else \
true; \
fi; \
local branch=\"pr-$number\"; \
local remote=\"${2:-upstream}\"; \
git fetch -fu \"$remote\" \"refs/pull/$number/head:$branch\" && \
git checkout \"pr-$number\"; \
}; f"
prmerge = "!f() { \
local number=\"${1:-}\"; \
number=\"${number#\\#}\"; \
if test -z \"$number\" || test \"$#\" -gt 2; then \
echo 'syntax: git pr <integer> [<remote-to-push>]'; \
exit 1; \
else \
true; \
fi; \
local branch=\"pr-$number\"; \
local remote=\"${2:-}\"; \
( \
git checkout master && \
git merge --ff-only \"$branch\" && \
git branch -d \"$branch\"; \
if test -n \"$remote\"; then \
git push \"$remote\" master; \
else \
true; \
fi; \
printf 'HEAD '; \
git rev-parse HEAD; \
) || (git checkout -; echo \"merge failed\"; exit 1;) \
}; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment