Firstly create a new Git branch:
git checkout -b my-new-branch
Do your changes and commit:
git commit -am "My changes."Now create the patch file by a diff from your branch and the development branch (f.e. master or develop):
git format-patch master --stdout > fix_empty_poster.patchAfterwards you can switch into a different branch, where you want to apply the patch file.
git checkout master
To check if the patch can be applied, use the following command:
git apply --check fix_empty_poster.patchTo check which impact the patch will have, use the following command:
git apply --stat fix_empty_poster.patchYou can also apply the patch by
git apply < fix_empty_poster.patch
But this command will not create a Git commit by one action.
For applying the patch, use the following command:
git am --signoff < fix_empty_poster.patchBy this command, the patch will be already commited into Git. So you'll the the following entry in your Git log, if you type
git log
commit 2839f6f8e408140956d121b2af28b55543e93ec0This article is based on Ariejan de Vroom's article.
Author: Peter
Date: Wed Mar 30 21:04:21 2016 +0200
Patch commit.
Signed-off-by: Peter
The commands in short
New branch:
git checkout -b my-new-branch
Do changes and commit:
git commit -am "My changes."
Create the patch:
git format-patch master --stdout > fix_empty_poster.patch
Checkout to your master branch (or any other):
git checkout master
Check if patch can be applied:
git apply --check fix_empty_poster.patch
Check the impact:
git apply --stat fix_empty_poster.patch
Apply and commit the patch:
git am --signoff < fix_empty_poster.patch