代码之家  ›  专栏  ›  技术社区  ›  Bite code

如何接受远程服务器的所有更改?

  •  9
  • Bite code  · 技术社区  · 14 年前

    我在拉一些分支,可以看到有很多变化。最终我不介意他们把我的都抹掉。

    我怎样才能全部接受它们,或者使用mergetool逐个合并文件?

    3 回复  |  直到 14 年前
        1
  •  8
  •   cdunn2001    13 年前

    只是:

        git clone $url
    

    说真的!那是最好的办法。

    你可以做各种各样的事情 git reset git branch 命令来移动引用,但唯一的目的是将提交保存在本地存储库中的某个位置,以供将来参考。如果这是目标,只需保持整个存储库的原样,并重新克隆源。

    只接受一个分支上的所有更改, foo

        git checkout foo
        git fetch origin +refs/heads/foo:refs/remotes/origin/foo
        git reset refs/remotes/origin/foo
    

    现在将指向与 origin --hard git重置 . 如果要先合并,请替换 fetch 具有 pull .

    您的本地回购中可能有一堆悬而未决的提交,git可能会在某一天清理这些提交,但有一段时间您仍然可以通过reflog访问它们。

        2
  •  6
  •   Austin Hanson    12 年前

    或:

    git status | grep "both " | cut -f2 | cut -f11 -d" " | xargs git checkout --theirs
    git status | grep "both " | cut -f2 | cut -f11 -d" " | xargs git add
    

    强制接受所有冲突的远程文件。

        3
  •  0
  •   Potherca    12 年前

    git checkout ours
    git checkout theirs -- *.php *.txt *.config modules themes includes scripts
    git commit -m "New version with all new key files from 'theirs'"
    

    只要我在第二次签出中得到了正确的文件和目录列表,就可以了。