代码之家  ›  专栏  ›  技术社区  ›  JP Silvashy Gautam Rege

解决了冲突后,git还抱怨吗?

git
  •  30
  • JP Silvashy Gautam Rege  · 技术社区  · 14 年前

    我通常 rebase 当我从我的队友那里得到改变时,我经常会有冲突:

    ...
    CONFLICT (content): Merge conflict in app/views/search/index.html.erb
    Auto-merging public/stylesheets/application.css
    CONFLICT (content): Merge conflict in public/stylesheets/application.css
    Failed to merge in the changes.
    Patch failed at 0001 organizing
    
    When you have resolved this problem run "git rebase --continue".
    If you would prefer to skip this patch, instead run "git rebase --skip".
    To restore the original branch and stop rebasing run "git rebase --abort".
    

    因此,在打开每个有冲突的文件后,修复它,然后提交修复的文件:

    ~/Projects/myApp[956f6e1...]% git rebase --continue
    You must edit all merge conflicts and then
    mark them as resolved using git add
    

    ~/Projects/myApp[64b3779...]% git rebase --continue                         
    Applying: organizing
    No changes - did you forget to use 'git add'?
    
    When you have resolved this problem run "git rebase --continue".
    If you would prefer to skip this patch, instead run "git rebase --skip".
    To restore the original branch and stop rebasing run "git rebase --abort".
    

    我一直都有这个问题,但我想我从来没有真正选择解决它,我会我总是变得懒惰和 git rebase --skip .

    我如何以正确的方式解决冲突?

    5 回复  |  直到 7 年前
        1
  •  38
  •   Mark Rushakoff    14 年前

    所以在打开每个有冲突的文件后,修复它然后提交修复的文件。。。

    问题是你不应该 commit a.txt 如果存在合并冲突,则shell日志应如下所示:

    $ vim a.txt # fix conflict
    $ git add a.txt
    $ # no commit between add and rebase!
    $ git rebase --continue
    

    git rebase --continue 将负责提交本身。

    我不知道如何“回到”你的承诺之前,当你在一个回扣中间。 git reset --hard HEAD git rebase --abort 在没有中间的情况下重新开始。

        2
  •  3
  •   BenMorel Manish Pradhan    10 年前

    至少还有一种方法可以让git继续说“您必须编辑所有合并冲突,然后使用git add将它们标记为已解决”,即使您已经这样做了。如果从git版本控制中删除文件,但将未版本的文件保留在工作树中,然后尝试执行重设基础,则可能会发生这种情况。

    我可以按以下方式解决此问题:

    1. 终止与 git rebase --abort
    2. 通过查看 git status
    3. 我把我的未版本文件移到了我的 tmp 目录
    4. 重做基础-在我的情况下 git svn rebase
    5. 如果你想让未版本的文件挂起,把它移回你想要的地方(我把我的放在tmp目录下)

    希望有帮助。

        3
  •  2
  •   Gil    10 年前

    当这种情况发生在我身上时,我意识到我在重新设置文件的基础时编辑了(并添加到了索引中)一个 没有冲突 ,我猜这可能是错的。 所以我用 git checkout -- <filename-with-no-conflict> ,然后 git rebase --continue ,而且成功了。

        4
  •  0
  •   VonC    7 年前

    在Git 2.14(2017年第3季度)中,这种建议是在一个不需要回答的反问句中给出的(比如 did you forget to use 'git add'? )将不再存在。

    看到了吗 commit 6963893 , commit 9932242 , commit 6c48686 (2017年5月11日) Jean-Noel Avila ( jnavila ) .
    Junio C Hamano -- gitster -- 在里面 commit e638108

    可用性:如果不需要回答,不要问问题

    错误时,git程序试图通过提供候选对象来帮助用户 接近不存在的命令。Git打印 以下内容:

        git: 'stahs' is not a git command. See 'git --help'.
        Did you mean this?
    
        stash
    

    然后退出。

    这个提示的问题是它没有正式表示为 提示,实际上鼓励用户回答问题,

    用户很不幸,他看到的是命令 ,并在命令行上回答“是”,有效地启动了 yes

    最初的错误是Git程序在中启动时 命令行模式(无交互)不得提问, 他们不会处理的。这是用户体验的一个混乱来源

    为了提高Git套件的通用性,下面的规则 已应用:

    如果这句话

    • 出现在非交互式会话中
    • 在退出前最后打印
    • 是针对用户(“您”)的问题

    这句话变成肯定句并提出了选择。

    就你而言 你忘了用“git add”吗? " is now replaced with :

    你应该 git add '将每个已解决冲突的文件标记为冲突。
    你可以跑了 git rm 在一个文件上接受“被他们删除”为它。

    更清楚了。

        5
  •  0
  •   stevec Zxeenu    4 年前

    我已经解决了合并冲突,但我仍然看到

    您有未合并的路径。

    git add <file that had conflicts> 从那以后一切都很好。

        6
  •  -2
  •   vladiim    12 年前

    我发现自己在同一条船上 git rebase --continue rm -fr .git/rebase-apply 但解决了这个问题