In the aftermath of a Git problem at work, I wanted to revert changes in PHP source code files. I wanted to re-commit my changes, so I need to change files directly in the checkout first. I'm working under Windows.
Here's what I did:
- Get patch string: Luckily, Tortoise Git offers windows such as Sync, Log and many other offer a context menu item 'Show changes as unified diff'
- Get a bash window. I ususally right-click in Explorer and use 'Git Bash Here'.
- Get the patch utility to listen: typing patch -R -p 1 followed by Enter means: Wait on stdin for the patch string, ignore the first path segment (which is a informationless a/ and b/ in all repos and all files). My patch.exe comes from Cygwin, whose bin folder is on my path variable.
- Revers-Apply the patch: Now paste the whole unified diff from step 1. Press Ctrl + D to tell patch.exe to start working