Using Git Patch for Temporary Changes

Here’s a case that comes up often when you are working on a code that is being developed at multiple locations and by multiple developers.

To do a full integration test on my local system, I need to change some of the paths in the test files. I have done this once and then saved them as a patch.

To save the diff as a patch

git diff -p > locat_test.patch

Applying the patch when doing the local testing

git apply local_test.patch

After the test, I discard the local repo back to the original state.

git reset --hard

This has helped me a lot. I have multiple such small patches in my local repo just to do these quick transitory changes to the code base for a specific location.

Do you know of any use case similar to this, please let me know?

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s