Last active
October 21, 2016 15:04
-
-
Save JadedEvan/a033e9883e77334bec5106e380406b96 to your computer and use it in GitHub Desktop.
How to revert a file to a known working state and apply upstream changes in a patch from a different branch.
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
# Check out the original file should receive the changes. This should be the version on your working branch | |
git checkout {MY-WORKING-BRANCH-SHA} -- path/to/my/file.txt | |
# Generate a diff of the file, ignoring space changes against a known branch. You should be on your working branch for this | |
git checkout my-working-branch | |
git diff HEAD..master --ignore-space-change -- path/to/my/file.txt > patch.diff | |
# Apply the patch. Note that you MUST use the same --ignore-space-change flag to apply properly | |
git apply --ignore-space-change patch.diff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment