Git error on commit after merge - fatal: cannot do a partial commit during a merge

前端 未结 18 1339
长情又很酷
长情又很酷 2020-12-07 07:15

I ran a git pull that ended in a conflict. I resolved the conflict and everything is fine now (I used mergetool also).

When I commit the resolved file

相关标签:
18条回答
  • 2020-12-07 07:28

    During a merge Git wants to keep track of the parent branches for all sorts of reasons. What you want to do is not a merge as git sees it. You will likely want to do a rebase or cherry-pick manually.

    0 讨论(0)
  • 2020-12-07 07:30

    Sometimes during the merge, if conflicts arise and there are deltas that need manual resolution. In such case fix the manual resolution for the files mentioned.

    Now if you issue,

    git status Lib/MyFile.php
    

    You will see output like

    On branch warehouse
    Your branch and 'origin/warehouse' have diverged,
    and have 1 and 1 different commits each, respectively.
      (use "git pull" to merge the remote branch into yours)
    
    All conflicts fixed but you are still merging.
      (use "git commit" to conclude merge)
    
    Changes to be committed:
    
        modified:   Lib/MyFile.php
    

    Since, you already staged the commit, you need just issue

    git commit
    

    And your commit will be done without any issue.

    0 讨论(0)
  • 2020-12-07 07:32

    I solved this with a completely different approach, using only Xcode's Source Control.

    Background: Another team Pushed changes to the remote Git repository (via Beanstalk). On my end, the .xcodeproj files came in under different directory, and the changes didn't take. Later, when I tried to commit, I received a Tree Conflict error in Xcode.

    Being nearly impossible to correct using Xcode, I replaced the .xcodeproj file with a downloaded version from the Git server. The result... the Xcode project appeared to clear up, however all the updates from the corrupt Pull were showing up as changes I made and were Staged for a Commit.

    However when trying to Commit, I received the same "fatal: cannot do a partial commit during a merge" error, discussed here.

    Here's how I solved the problem... (Now, understand that I'm a rookie programmer, so I could lack some understanding... but my ignorance led me to find another way to do this.) First, I Cloned my master Branch into a secondary Branch and switched to that branch. Then I created a Working Copy and placed the directory to that working copy outside of the original project directory. (I don't know if this was necessary, but its what I did as I read other troubleshooting techniques.) Then I switched branches to the master, where I realized all my Staged files (changes to Commit) were gone. To make sure all the files were updated to the latest changes made by the other party, I created a new branch called ThirdBranch, which duplicated all files, Pushed it to the Git Server and let Beanstalk compare my server version of the master branch to the ThirdBrach branch I just Pushed (line by line), and all the changes by the other party were present on my Xcode. This meant that my master repository and the Git master repository were the same, which verifies that I solved the problem using Xcode, only.

    Don't ask me how, beyond what I just described... and certainly fill in the gaps I left out. I'm new at this and I don't understand everything. Maybe an experienced programmer can separate the irrelevant info from the relevant and recreate this technique more clearly, which is in part why I'm posting this.

    This is a duplicate answer to duplicate question as at: Failed Xcode Git Merge is stuck

    0 讨论(0)
  • 2020-12-07 07:33

    I found that adding "-i" to the commit command fixes this problem for me. The -i basically tells it to stage additional files before committing. That is:

    git commit -i myfile.php
    
    0 讨论(0)
  • 2020-12-07 07:33

    I got this when I forgot the -m in my git commit when resolving a git merge conflict.

    git commit "commit message"
    

    should be

    git commit -m "commit message"
    
    0 讨论(0)
  • 2020-12-07 07:33

    If it is in Source Tree, we should explicitly mark a file as resolved after the conflicts are resolved. Select file that was just resolved to no conflicts. Then Actions -> Resolve Conflicts -> Mark Resolved. If you have multiple files, do the same for all. Commit now.

    0 讨论(0)
提交回复
热议问题