Git merge error “commit is not possible because you have unmerged files”

后端 未结 7 1110
陌清茗
陌清茗 2020-11-29 17:11

I forgot to git pull my code before editing it; when I committed the new code and tried to push, I got the error "push is not possible".

At tha

7条回答
  •  一生所求
    2020-11-29 17:21

    Since git 2.23 (August 2019) you now have a shortcut to do that: git restore --staged [filepath]. With this command, you could ignore a conflicted file without needing to add and remove that.

    Example:

    > git status
    
      ...
      Unmerged paths:
        (use "git add ..." to mark resolution)
          both modified:   file.ex
    
    > git restore --staged file.ex
    
    > git status
    
      ...
      Changes not staged for commit:
        (use "git add ..." to update what will be committed)
        (use "git restore ..." to discard changes in working directory)
          modified:   file.ex
    
    

提交回复
热议问题