tags:

views:

251

answers:

2

I have a large website that I am moving into a new framework and in the process adding git. The current site doesn't have any version control on it.

I started by copying the site into a new git repository. I made a new branch and made all of the changes that were needed to make it work with the new framework. One of those steps was changing the file extension of all of the pages.

Now in the time that I have been working on the new site changes have been made to files on the old site. So I switched to master and copied all of those changes in.

The problem is when I merge the branch with the new framework back onto master there is a conflict on every file that was changed on the master branch.

I wouldn't be to worried about it but there are a couple of hundred files with changes. I have tried git rebase and git rebase --merge with no luck.

How can I merge these 2 branches without dealing with every file?

A: 

I figured out a fix. Since the renaming of the files was done by a script I was able to copy the new .php files and rerun the script before the merge. Since the files had the same name the merge worked without conflicts.

Here are the steps for the whole process.

  1. Create git repo git init
  2. Copy existing files in
  3. Commit
  4. Run script to rename files
  5. Commit
  6. Create a branch but don't check it out
  7. Make fixes committing changes as you go
  8. Checkout the branch you made in step 6
  9. Copy the new versions of the files
  10. Run the script to rename the files (this should replace the ones from the first run)
  11. Commit
  12. Checkout master
  13. merge the branch into master

This works because to git the changes were made to the files with the new name.

Kevin
A: 
Jakub Narębski
I played with "git rebase -m" and had the same problem. That looks like the same process I used. Every time I would do git merge new-feature it would say that the original files were deleted.
Kevin
Looking over your code again there was one difference. You used git mv and my script just renamed the files it didn't call git mv. Looking back at the commit though it shows the files being renamed not deleted and added back. Maybe git mv is doing something more than the auto file move detection.
Kevin
After renaming file via "mv oldname newname", or via some script, you need to do "git add newname", and use either "git rm --cached oldname" or use "git commit -a" to pick up the deletion part of rename. "git mv oldname newname" does that for you, but Git's rename detection works independent on how you did rename.
Jakub Narębski