GIT: Download a Patch of a Commit from GitHub

by Oliver 15. November 2017 09:00

We are building our branch portal software discoverize on top of the mature Orchard CMS and incorporate important changes from the Orchard sources into our own software.

Today, I wanted to add the CacheManagerExtensions class to discoverize to take advantage of some optimizations to the cache population strategy. The first commit contained changes to no less than 27 files. Manual work: go away!

So I thought to myself: I'll just get the patch for this commit and apply it to my working directory :-)

Well, guess what? There's no magic patch button on the commit page anywhere.

Google and this blog post to the rescue…

Download a Commit as a Patch

It turns out to be as easy as adding .patch to the end of the commit url – and you get a beatiful text screen that you can save to a .patch file.

Applying as much of a patch as possible

Use git apply --reject abc.patch to apply all of the patch that can be applied to your current working directory – for the rest of the differences in the commit, reject files (.rej) will be created to not loose track of them.

And that's all.

Happy patching!

Comments are closed

About Oliver

shades-of-orange.com code blog logo I build web applications using ASP.NET and have a passion for javascript. Enjoy MVC 4 and Orchard CMS, and I do TDD whenever I can. I like clean code. Love to spend time with my wife and our children. My profile on Stack Exchange, a network of free, community-driven Q&A sites

About Anton

shades-of-orange.com code blog logo I'm a software developer at teamaton. I code in C# and work with MVC, Orchard, SpecFlow, Coypu and NHibernate. I enjoy beach volleyball, board games and Coke.