6

Is there an easy way to reformat a regular (unified) diff patch into a git-format patch? What I want to do, is take a regular patch someone sends me and apply it with git, adding author information – as if it were a git-format patch.

I don't really want to start manually rewriting the patch, so I was wondering if there is perhaps a git command I haven't found out about yet that does this.

It seems like a problem others must have had before...

Thanks!

2
  • 1
    I don't know if this helps, but if you use diff -u file1 file2 will generate the patch with the format as git-patch Commented Feb 28, 2011 at 3:25
  • But without author information... I would like to change the diff into git-patch format, adding the author so I can give credit. Commented Feb 28, 2011 at 15:05

1 Answer 1

3
git apply < patch; git commit; git format-patch HEAD^
Sign up to request clarification or add additional context in comments.

2 Comments

Hmm... But I would have applied the patch and committed it without author information here. I want to add author information before I apply and commit, so the person who sent the non-git diff still gets credit.
@wvh You can pass the --author flag to commit, and I guess you don't need the format-patch step.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.