简体   繁体   中英

Introducing Edited Files Into a Git Branch and then merging

This situation I have is the following. I have an old project in aa Solution I will call Old Project A and Old Solution A . It was a divergent branch (just a copy of the SVN for development) from the main Project and Solution. This was in SVN Tortoise. I have a copy of this Old Project A and Old Solution A on my computer.

Then we put the main line of our solution and project into Git. Much development has taken place and there are many commits in Git.

So I now have The Git Project A within Git Solution A .

I want to introduce The Old Project A into a branch of the Git repository.

What I have done is created 2 new branches I will call NewBranch A and NewBranch B , both from the master branch.

From NewBranch B I deleted the Git Project A and replaced it with Old Project A , committed all the modified files but did not commit all the deleted files (which had been added in the newer Git Project A ).

git checkout NewBranch B
git merge NewBranch A

But this just keeps the Old Project A code and does not merge the Git Project B . I was of course expecting merge conflicts. I wanted them to sort them out manually. But all I got was the Old Project A code.

How can I merge the Old Project A code with the Git Project B and then manually sort the conflicts ?

I can see 2 options for your situation.

  1. Just use Meld or other merging tool to merge manually on the new branches. This is more controlled.

But if you insist on using git,

  1. Create the NewBranch from very first git commit of master branch instead from latest master. Copy all old code there and commit. Now merge latest master to NewBranch. This should trigger conflicts as you expected and you can resolve conflicts manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM