Creating and Applying Git Patches

To export a Git Patch, Use

git format-patch -1 <sha>

where <sha> is the Git ChangesetID, OR Use

git format-patch -1 HEAD

if the last commit is the commit you want to export

 

To view changes contained in a Git Patch, Use

git apply --stat patchName.patch

To test the patch before you actually apply it, Use

git apply --check patchName.patch

To apply a patch, Use

git am patchName.patch

If a patch fails, Use the following to abort

git am --abort
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s