Reputation: 289
So last year I had one of our developers restructure our git repo, moving files around and such. Unfortunately, I didn't look at his work too closely and it appears that he lost some history (ie did the git rm/git add in different commits or did something else so git didn't recognize renames and treated them as new files).
A couple months ago I merged this restructuring into a branch I've been working on. I've done a whole bunch of changes on this branch, some of which affects files with lost history.
Now, I'm trying to figure out how to recover from this snafu. One strategy I'm considering is to create a new branch and cherry pick the commits I want and then do the restructuring myself. Unfortunately there are 100's of commits so this is going to be very time intensive. Is this the correct strategy, or is there something obvious I'm missing?
The biggest problem is when I'm pulling in changes that are in our production branch. Because the renames/moves weren't properly tagged, I get a whole lot of 'deleted by us' messages. The repo is an ASP.NET site. In the old repo structure, it was just the root folder for the site. I moved all of this into a subfolder, and moved some dependencies up and to a new folder.
So, previous structure:
Web.config
Default.aspx
Default.aspx.cs
Dependencies/
Current structure:
Website/
Web.config
Default.aspx
Default.aspx.cs
Dependencies/
If I make a change to Default.aspx on our live branch, which still has the previous structure, and then pull it into this troublesome branch, I get this:
Website/
Web.config
Default.aspx
Default.aspx.cs
Default.aspx (deleted by us)
Dependencies/
Upvotes: 2
Views: 880
Reputation: 289
After coming across the problem again, I finally figured out this has to do with two different git config values that were not properly set on my system.
Namely:
git config diff.renames true
git config merge.renamelimit 10000
Setting these two fixed the issue, and git properly detected the files moving.
Upvotes: 1