如何从远程接受所有更改?
我正在做一个 pull origin some_branch ,可以看到有很多变化。最终我不介意他们是否抹掉我的一切。
我怎样才能接受它们全部或使用 mergetool 并一一合并文件?
I'm doing a pull origin some_branch and can see there are a lot of changes. Eventually I don't mind if their erase all mine.
How can I accept them all instead or using mergetool and merge files one by one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只是:
说真的!这是最好的办法。
您可以执行各种
git reset
和gitbranch
命令来移动引用,但唯一的目的是将您的提交保留在本地存储库中的某个位置以供将来参考。如果这是目标,只需保持整个存储库不变,然后重新克隆源。要仅接受一个分支上的所有更改,
foo
:foo
现在将指向与origin
上的foo
相同的提交>。如果你想清除工作目录中的文件,请将--hard
添加到git reset
中。如果要先合并,请将fetch
替换为pull
。您的本地存储库中可能有一堆悬而未决的提交,git 可能有一天会清理这些提交,但在一段时间内您仍然可以通过引用日志访问它们。
Just:
Seriously! That's the best way.
You could do all sorts of
git reset
andgit branch
commands to move the refs, but the only purpose would be to keep your commits somewhere in your local repository for future reference. If that's the goal, just keep the whole repository as is, and re-clone the origin.To accept all changes on just one branch,
foo
:foo
will now point at the same commit asfoo
onorigin
. If you want to blow away the files in your working directory, add--hard
togit reset
. If you want to merge first, replacefetch
withpull
.You may have a bunch of dangling commits in your local repo, which git may clean-up someday, but for awhile you can still access them via the reflog.
或者:
强制接受所有冲突的远程文件。
Or:
which forces accepting all conflicting remote files.
这是我使用的方法,看起来还可以。我有一个名为“他们的”的分支,其中包含遥控器中所有内容的新版本。名为“我们的”的版本是我基于他们很久以前的版本所做的工作,其中有太多不相关的更改,但我想保留许多添加内容(站点/所有的新子目录)。
只要我在第二次签出时获得正确的文件和目录列表,就应该没问题。
如果我希望历史基于“他们的”分支,我可能会想反过来做。
Here's the approach I used, which seems to be OK. I have a branch called "theirs" which contains the new version of everything in the remote. A version named "ours" is my work based on a long-ago version of theirs, which too many irrelevant changes but many additions (new subdirectories of sites/all) that I want to keep.
As long as I got the list of files and directories in the second checkout correct, this should be fine.
If I wanted the history to be based on the "theirs" branch I might want to do this the other way round.