Git在我的文件中将HEAD标记合并 [英] Git merge left HEAD marks in my files

查看:636
本文介绍了Git在我的文件中将HEAD标记合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Git在命令行中合并文件,当出现错误消息告诉我合并被中止时。



我认为这是它的结束,但后来我意识到我的文件中存在gitmarks。像这样:

  start = 
表达式

validchar =
[0 -9a-zA-Z _ $!^ _ - = @#$%^& * /。]

整数=
<<< <<< < HEAD
位数:[0-9] +
{返回digits.join(); }
=======
sign: - * digits:[0-9] +
{return sign + digits.join(); }
>>>>>>> gh-pages

这些文件不是由我编辑的,而是用插入的行显示的:

<<<<<<<<<<<<
  • 改变后的代码行

  • 一串等号( =======
  • code>)
  • 新版本的代码

  • 另一行以大于符号和分支名称(>>>>>>> gh-pages< / code>
    $ b< b&更糟糕的是,文件内容不再有序。有谁知道我如何让这些文件恢复正常,并且我在gh分支中所做的更改合并到主分支中?

    解决方案

    这些是冲突标记。您仍然处于合并过程中,但有一些Git无法自动合并的部分。您将需要手动编辑这些部分到然后提交结果。






    例如,在您的特定情况下,您可能会想要像这样解决它(注意 - 右边的箭头/文本只是我的笔记,而不是你要输入到文件中的东西):

      integer = 
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<整数= HEAD< - +在这里删除位
    位数:[0-9] + |
    {return digits.join(); } |
    =======< - +
    sign: - * digits:[0-9] +
    {return sign + digits.join(); }
    >>>>>>> gh-pages < - 和这个

    ,因此您将文件另存为...

     整数= 
    符号: - * digits:[0-9] +
    {return sign + digits.join(); }


    I tried to merge a file in the command line using Git, when an error message appeared telling me the merge was aborted.

    I thought that was the end of it, but then I realized there are gitmarks in my files. Like so:

    start =
        expression
    
    validchar = 
        [0-9a-zA-Z_?!+\-=@#$%^&*/.]
    
    integer = 
    <<<<<<< HEAD
        digits:[0-9]+
            { return digits.join(""); }
    =======
        sign:"-"* digits:[0-9]+
            { return sign + digits.join(""); }
    >>>>>>> gh-pages
    

    The files have been edited not by me and show lines inserted with:

    • HEAD after less than signs (<<<<<<< HEAD)
    • lines of changed code
    • a string of equals signs (=======)
    • the new version of the code
    • another line starting with greater than signs and the name of the branch (>>>>>>> gh-pages)

    What's worse is that the file contents are no longer in order. Does anyone know how I get those files back to normal, and the changes I made in the gh-branch merged into the master branch?

    解决方案

    Those are conflict markers. You're still in the process of merging, but there were some parts that Git couldn't merge automatically. You'll need to hand-edit those parts to what you want them to be and then commit the results.


    For instance, in your particular case, you'd probably want to resolve it like this (note - the arrows/text on the right are just my notes, not something you'd type into the file):

    integer = 
    <<<<<<< HEAD                                  <-+ remove the bits here
        digits:[0-9]+                               |
            { return digits.join(""); }             |
    =======                                       <-+
        sign:"-"* digits:[0-9]+
            { return sign + digits.join(""); }
    >>>>>>> gh-pages                              <-- and this
    

    and thus you'd save the file as...

    integer = 
        sign:"-"* digits:[0-9]+
            { return sign + digits.join(""); }
    

    这篇关于Git在我的文件中将HEAD标记合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆