0

在我的 git 项目文件夹中,我需要创建一个不同版本的软件,这当然可以通过创建新分支来完成。关键是我需要在不失去版本控制的情况下重命名不同的文件;分支 1 旧名称的更改必须合并到分支 2 新名称中。我已经尝试过了,但它没有用。

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

有什么方法可以做到这一点吗?在此先感谢您的帮助。

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. 如果我在 branch-2/new-file 中做了一个小改动,提交它然后重复上面的测试,一切都正常了。完美的。

  3. 当在重命名的文件(在这种情况下为 branch-2/new-file)中进行重大更改时,就会出现问题。再次进行第一次测试而不是合并,git 不会像重命名文件那样识别新文件,它会显示此冲突消息并将旧文件添加到分支 2 中。
    CONFLICT (modify/delete): old-file deleted in HEAD and modified in branch-1. Version branch-1 of old-file left in tree.

有没有办法强制 git 在任何情况下识别重命名的文件?现在我知道,如果我对重命名文件中所做的更改进行更多提交,系统可以工作,但必须有更好的解决方案。谢谢。

4

0 回答 0