Skip to content

Instantly share code, notes, and snippets.

@esprengle
Forked from mitsuhiko/.gitconfig
Created January 30, 2021 20:22
Show Gist options
  • Select an option

  • Save esprengle/7338832a4687d068e7a0cb085d2878e0 to your computer and use it in GitHub Desktop.

Select an option

Save esprengle/7338832a4687d068e7a0cb085d2878e0 to your computer and use it in GitHub Desktop.
Adds the ultimate of all pull request commands to git
# Alternatively don't use slog but something else. I just like that more.
[aliases]
slog = log --pretty=format:"%C(auto,yellow)%h%C(auto)%d\\ %C(auto,reset)%s\\ \\ [%C(auto,blue)%cn%C(auto,reset),\\ %C(auto,cyan)%ar%C(auto,reset)]"
addprx = "!f() { b=`git symbolic-ref -q --short HEAD` && \
git fetch origin pull/$1/head:pr/$1 && \
git fetch -f origin pull/$1/merge:PR_MERGE_HEAD && \
git rebase --onto $b PR_MERGE_HEAD^ pr/$1 && \
git branch -D PR_MERGE_HEAD && \
git checkout $b && echo && \
git diff --stat $b..pr/$1 && echo && \
git slog $b..pr/$1; }; f"

How it works

git addprx 42

Adds pull request 42 as branch "pr/42" and rebases the changes against the current branch. What this means is that even if the pull request (of a bugfix was against master) it will now be rebased against the current branch (which could be the maintenance branch).

It also prints out a diffstat and all the commits with their new hashes at the end.

screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment