2

Here is my scenario:

I want to resolve a conflict in my repository and, in the same time, I also want to let the user to be able to commit other files without having to commit the resolved file. I tried the following:

  1. git status: 1.txt(conflict) 2.txt(modify)

  2. git resolve: 1.txt(modify) resolve the conflict

  3. git commit 2.txt //Only commit 2.txt

  4. git show log : 1.txt(modify) 2.txt(modify)

On the submission list, I only submitted 2.txt, but when viewing the log, 1.txt was submitted by default, why is this happening, and at the same time, the file status of 1.txt is still modify, how to parse this, I am a bit confused? Thanks in advance for your help!

potter
  • 53
  • 5

3 Answers3

0

Conflicts always need to be resolved before committing.

If you unselect a file then the changes are not part of the commit, i.e. the file stays in the unmerged version in the commit.

MrTux
  • 32,350
  • 30
  • 109
  • 146
0

I checked the source code of TortoiseGit and found that it restored the unchecked files after submission

potter
  • 53
  • 5
0

You need to navigate to the file currently modified, in your case 1.txt(modify)

you will notice in this file Git has added something similar to <<<<<<head>>>>>> This will show you where the current origin is, and then your current change underneath it.

Please Make sure you have resolved this conflict by deleting the correct set of code in the outlined file. After you do this you can continue with your commit.

Hope this helps

Sweet Chilly Philly
  • 3,014
  • 2
  • 27
  • 37
  • Chily Philly Thank you for your answer, your conflict resolution method is correct, but I mean that after conflict resolution, I did not select the file to be merged when doing Commit. At the same times, I checked the log submission information, 1.txt has been submitted by default Commit. – potter Jun 22 '20 at 05:04
  • You do not need to select the file to be merged. You have already selected it to be merged, which is why you have a conflict. Once you resolve the conflict Git will continue with the Merge that got stopped midway, it basically is just continuing the process that you started. I beleive you did select the file to be commited, probably without realiseing if you think you didnt. – Sweet Chilly Philly Jun 22 '20 at 21:25