Tre*_*key 1 git git-pull git-merge git-workflow
我想从存储库中取出,我相信来自该存储库的任何更改集与我的相撞,是更好的选择.
我如何自动化拉动,这样我就不必处理任何合并冲突,而且我从中拉出的存储库总能赢得这场战斗?
看看命令行选项,我不确定git pull --squash我是否正在寻找,或者我是否必须采用某种合并策略.我无法弄清楚我会传递给谁
-s <strategy>
--strategy=<strategy>
Run Code Online (Sandbox Code Playgroud)
要么
-X <option>
--strategy-option=<option>
Run Code Online (Sandbox Code Playgroud)
如果这确实是我应该使用的标志之一.
您正在寻找recursive具有该选项的策略theirs.
git pull -s recursive -X theirs
Run Code Online (Sandbox Code Playgroud)
从git-pull手册页:
recursive
This can only resolve two heads using a 3-way merge algorithm. When
there is more than one common ancestor that can be used for 3-way
merge, it creates a merged tree of the common ancestors and uses that
as the reference tree for the 3-way merge. This has been reported to
result in fewer merge conflicts without causing mis-merges by tests
done on actual merge commits taken from Linux 2.6 kernel development
history. Additionally this can detect and handle merges involving
renames. This is the default merge strategy when pulling or merging
one branch.
The recursive strategy can take the following options:
ours
This option forces conflicting hunks to be auto-resolved cleanly by
favoring our version. Changes from the other tree that do not
conflict with our side are reflected to the merge result. For a
binary file, the entire contents are taken from our side.
This should not be confused with the ours merge strategy, which does
not even look at what the other tree contains at all. It discards
everything the other tree did, declaring our history contains all
that happened in it.
theirs
This is the opposite of ours.
Run Code Online (Sandbox Code Playgroud)
但是,这真的不是一个好主意.即使您相信上游的更改是正确的,您如何知道它们适用于不会导致冲突的更改?
我个人更喜欢git pull --rebase直接前进,git pull并逐个检查每个冲突的提交.
| 归档时间: |
|
| 查看次数: |
107 次 |
| 最近记录: |