Update post to 2015

This commit is contained in:
Ariejan de Vroom 2015-06-11 00:54:16 +02:00
parent 0d7ec267c6
commit 849aa99688

View File

@ -1,20 +1,20 @@
+++
date = "2009-10-26"
title = "How to create and apply a patch with Git"
tags = ["git", "patch", "git apply", "git am", "apply", "am", "signed-off-by"]
tags = ["git", "patch", "sign-off"]
slug = "how-to-create-and-apply-a-patch-with-git"
+++
Git is quite common nowadays and a lot of people are asking me how they can create a patch file. Creating a patch file with git is quite easy to do, you just need to see how it's done a few times.
Creating a patch file with git is quite easy to do, you just need to see how it's done a few times.
This article will show you how to create a patch from the last few commits in your repository. Next, I'll also show you how you can correctly apply this patch to another repository.
~
<strong>Before you start</strong>
### Before you start
To make creating patches easier, there are some common git practices you should follow. It's not necessary, but it will make your life easier.
If you fix a bug or create a new feature do it in a separate branch!
Let's say you want to create a patch for <a href="http://github.com/ariejan/imdb">my imdb gem</a>. You should clone my repository and create a new branch for the fix you have in mind. In this sample we'll do an imaginary fix for empty posters.
Let's say you want to create a patch for my <a href="http://github.com/ariejan/imdb">imdb</a> gem. You should clone my repository and create a new branch for the fix you have in mind. In this sample we'll do an imaginary fix for empty posters.
git clone git://github.com/ariejan/imdb.git
cd imdb
@ -24,7 +24,7 @@ Now, in the new <code>fix_empty_poster</code> branch you can hack whatever you n
When you're satisfied with all you changes, it's time to create your patch. FYI: I'm assuming you made a few commits in the <code>fix_empty_poster</code> branch and did <em>not</em> yet merge it back in to the <code>master</code> branch.
<strong>Creating the patch</strong>
### Creating the patch
Okay, I've made some commits, here's the <code>git log</code> for the <code>fix_empty_poster</code> branch:
@ -45,7 +45,7 @@ This will create a new file <code>fix_empty_poster.patch</code> with all changes
Now, you have a patch for the fix you wrote. Send it to the maintainer of the project ...
<strong>Applying the patch</strong>
### Applying the patch
... who will apply the patch you just sent! But, before you do that, there are some other steps you should take.