Git Help? How to build a patch from commits


Git Help? How to build a patch from commits

Posted by Luis Majano
Nov 15, 2010 10:45:00 UTC

 

This is more of a question post than a learning post, so your feedback is welcomed.  Here is what I am trying to do.  I have several commits into a branch and I would like to build a patch file that has all the files that where changed from commit X to commit Y.  Example:

 

Commit 1 – Changed files

/plugins/BeanFactory.cfc
/interceptors/SES.cfc

Commit 2 – Changed files

/interceptors/SES.cfc
/interceptors/Security.cfc

Commit 3 – Changed files

/web/services/PluginService.cfc

 

Now I want to run SOMETHING or do SOMETHING automated that can produce the following patch:

PATCH

/plugins/BeanFactory.cfc
/interceptors/SES.cfc
/interceptors/Security.cfc
/web/services/PluginService.cfc

 

So any Git gurus can comment on how to achieve this.


Eapen

This is probably old and you have already figured it out but it looks like the best way is to squash your commits and create a patch from the single commit.

Luis Majano

Hmm, no I have not figured it out yet. How would you go about it? Create a branch, then squash? I have never done that, any insight would help.

Eapen

Yes, ideally you would work on each bug/feature as a branch and use git rebase --interactive (http://www.gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) to squash commits and then create a patch file. I occasionally use squash to combine several small updates into a single update.

I haven't ever created a patch file but I saw that the Tower software (that you highlighted) has the ability to do that when you right-click on a commit.