Created
March 20, 2012 19:51
-
-
Save cookrn/2140571 to your computer and use it in GitHub Desktop.
How to Create and Apply a Patch w/ Git Across Similar Repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## In your origin repo that contains the changes you want patched onto similar repos | |
# | |
# A "similar repo" might be one that was using the same codebase in the past, but was not forked | |
# If you have been working on a feature branch, just grab all commits different between the branch and master | |
git format-patch master | |
# Or, if you would like to grab the last few commits that make up a feature change... | |
git format-patch -2 | |
# ...where "-2" is the number of commits you'd like to go back in history and create patches for | |
# This will create a patch file for each commit | |
# DO NOT run both of these commands |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming your patch files have been moved into the root directory of the project where they will be applied... | |
# Check the changes in the patch | |
git apply --stat 0001-my-changes.patch | |
# Check that the patch can be applied | |
git apply --check 0001-my-changes.patch | |
# Apply the patch | |
git am --signoff < 0001-my-changes.patch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment