Skip to content

Instantly share code, notes, and snippets.

@antirez
Last active April 28, 2016 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antirez/c071e4112fb72a6f8cab1dbe2ad13c58 to your computer and use it in GitHub Desktop.
Save antirez/c071e4112fb72a6f8cab1dbe2ad13c58 to your computer and use it in GitHub Desktop.

Hello and thanks for reading,

I've a Redis pull request that no longer applies because, for example, one line where there was a < b is now a > b, otherwise the patch would apply cleanly.

if I try to cherry pick the commit and resolve the conflicts, it works, it's just a lot of useless work editing the conflicting code to merge properly and there is even the risk of making mistakes.

An alternative is to:

  1. Modify back the source code to a < b with a commit called FOO.
  2. Apply the pull request commit cleanly with cherry pick.
  3. Revert to a > b and amend the commit to make the change.

However this way I've the spurious commit FOO. If I rebase with rebase -i and squash the commit, the PR author name is removed from the history, which is very unfortunate. Is there a better alternative? Thanks in advance.

@jennings
Copy link

jennings commented Apr 28, 2016

It's not super elegant, but maybe you can use the GIT_AUTHOR_X env variables to set the authorship?

Starting with the series of commits you've described (revert, cherry pick, revert-the-revert), I think this does it:

git checkout pr
git reset --soft master
GIT_AUTHOR_NAME='Joe Smith' GIT_AUTHOR_EMAIL='joe@example.com' GIT_AUTHOR_DATE='2016-04-28 07:00:00 -0700' git commit -m 'original commit message'

This leaves the pr branch with one commit in it, and it's marked as being authored by the original committer.

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