GitExtensions 2.24 and Apply Patch pitfall

Today I survived a shocking experience.  I’m working on an open source framework. Some of the features I’ve been doing at home on a cloned git respository. I have commited about 6 times for a feature. Another change of the feature I was doing on another machine at my workplace. These changes were another two commits. I then patched the two commits I did on my work computer and applied them at home upon the other six commits with gitextensions (version 2.24).

When I applied the patches gitextensions was hanging indefinitely in the patch apply mode. After waiting for about 5 minutes I aborted the patching process. This left my whole repository in the middle of rebase state. Worst of all was that all my commits from the last week where gone! My blood pressure raised immediately. I tried several approaches: Abort the merge process several times, skip the patches etc. but none of these approaches were successful. Git always complaint that the folder .git/rebase-apply could not be removed. How can this state be resolved? I’ll show you how!

You need to do the following steps:

  1. Close gitextensions
  2. Open your repository in your file browser and delete the folder .git/rebase-apply
  3. Open the folder .git/logs/refs/heads/ and open the file master with your favorite editor
  4. Look for the commit you need
fd16b3de73...df221c0 cb288d1f89a5565a...df1a93a44e User  1318178002 +0200	commit: Text
cb288d1f89...a93a44e 15b008d9e5713868...gdf7345414 User  1318451633 +0200	commit: Text
  1. You need to copy the second SHA1 hash of the desired commit.
  2. Open git bash and type
git checkout -b featurename 15b008d9e5713868...gdf7345414
// this will create a branch with name "featurename"
  1. Re-apply the patches one by one with apply patch and choose a single file in the order of the patch prefix!
  2. You are saved!

Hope that will help some people until the bug is resolved!
Caution: I will not take any responsibility when you mess up your repository even more. Deleting folders in .git is dangerous and can lead to serious damage of your repository! Be cautious!

About the author

Daniel Marbach

Add comment

By Daniel Marbach

Recent Posts