Resolving a 'both added' merge conflict in git?

后端 未结 3 1540
北恋
北恋 2020-12-04 07:48

I\'m rebasing in git, and one conflict I get is \'both added\' - that is, exactly the same filename has been added independently in my branch, and in the branch I\'m rebasin

3条回答
  •  情深已故
    2020-12-04 08:28

    I sometimes find it confusing using the --theirs and --ours options to identify where the file will come from. Most of the time mine will be in the branch I am rebasing which is referred to by --theirs!

    You can also use git checkout -- src/MyFile.cs

    Where the can be replaced either by the branch name or commit-id that contains the file you wish to keep.

    git checkout 6a363d8 -- src/MyFile.cs

    git checkout my_branch -- src/MyFile.cs

    git checkout HEAD -- src/MyFile.cs

提交回复
热议问题