Different file name in a specific branch

617 views Asked by At

In my git project folder, I need to create a different version of the software, something that of course I can do by creating new branches. The point is that I need to rename different files without loosing the version control; a change in branch-1 old-name must be merged in branch-2 new-name. I've tried with this but it didn't work.

git mv old-name new-name
git add -A

Is there any method to do this? Thanks in advance for your help.

MORE INFO
Let's say that the two projects are very similar, think about two different versions of the same one. Now that I start working on the second version, I'm thinking about the code maintaining and I realized that the best option for me is the possibility to control them version together. The point is that i need to rename most of the files in the folder, and change in there basically the name of classes and functions. So, in the new branch-2, I've renamed the files with git mv old-name new-name and I've made a couple of tests.

  1. Starting with the same contents in the two files, If I make a change in branch-1/ old-file and then I merge branch-1 in branch-2, the modification is visible as expected in new-file.

  2. If I make a small change in branch-2/ new-file, commit it and than repeat the test above, again everything works fine. Perfect.

  3. The problem comes when a big change is done in a renamed file, branch-2/ new-file in this case. Doing again the first test and than merging, git does not recognized the new-file like a renamed one, it shows this conflict message and it adds the old-file in the branch-2.
    CONFLICT (modify/delete): old-file deleted in HEAD and modified in branch-1. Version branch-1 of old-file left in tree.

Is there a way to force git to recognize the renamed files in any case? Now I know that if I make more commits for the changes that I make in the renamed files, the system works but there must be a better solution for this. Thanks.

0

There are 0 answers