我們可以通過以下方式重現此問題:
- 設定
git remote add proxy [email protected]:pingcap/tidb-engine-ext.git git remote add tikv [email protected]:tikv/tikv.git git fetch proxy 3f55709e6678c687195fbbd59662459aa348d039 git fetch tikv b448214b8f2c0a6a9ba2381a1983ce20e6514218 - 將 tikv 的提交合并
b4482到代理中3f557git checkout -b test 3f55709e6678c687195fbbd59662459aa348d039 git merge b448214b8f2c0a6a9ba2381a1983ce20e6514218
有很多不相關的沖突,所以不要看它們。我們只查看components/resolved_ts/src/endpoint.rs第 502 行,它說
let resolved_ts = observe_region.resolver.resolve(ts).min();
但是,“他們的”版本是
let resolved_ts = observe_region.resolver.resolve(ts);
現在,我決定用“他們的”替換整個檔案,所以我運行
git checkout --theirs components/resolved_ts
Updated 1 path from the index
然后我發現
let resolved_ts = observe_region.resolver.resolve(ts).min();
是的,該檔案沒有更改為“他們的”。真奇怪。
但是,如果我運行
git checkout b448214b8f2c0a6a9ba2381a1983ce20e6514218 -- components/resolved_ts
該檔案更改為“他們的”。現在更奇怪了。既然如果這行得通,為什么git checkout --theirs會失敗?
誰能告訴我為什么會這樣?
我的工具鏈是
git --version
git version 2.30.1 (Apple Git-130)
uj5u.com熱心網友回復:
如果您git merge更仔細地檢查輸出,您將看到以下內容:
Auto-merging components/resolved_ts/src/endpoint.rs
Auto-merging components/resolved_ts/src/cmd.rs
將其與例如:
Auto-merging Makefile
CONFLICT (content): Merge conflict in Makefile
Auto-merging Cargo.toml
CONFLICT (content): Merge conflict in Cargo.toml
請注意,對于最后兩個檔案中的每一個,我們如何首先看到:
Auto-merging
接著:
CONFLICT (content):
后跟檔案名。但是,對于endpoint.rsand cmd.rs,我們看到Auto-merging后面跟著 ... 什么都沒有,這表明自動合并起作用了。
如果您檢查索引中的內容,則不會留下“他們的”版本:
$ git ls-files --stage components/resolved_ts/src/endpoint.rs
100644 a4e5f6e38641e12820167e715e8666b844943f40 0 components/resolved_ts/src/endpoint.rs
同樣,git status --short顯示:
$ git status --short | grep components/resolved_ts/
M components/resolved_ts/src/cmd.rs
UU components/resolved_ts/src/resolver.rs
M components/resolved_ts/tests/mod.rs
請注意,endpoint.rs不在此串列中:存在沖突,但很容易自動解決,Git 不僅解決了它,而且git add在結果上呼叫。 這就是為什么--theirs什么都不做:索引中沒有“他們的”版本。在索引中確實有一個版本的一個匹配components/resolved/路徑——它是:theirs
Updated 1 path from the index
來自上面——是UU components/resolved_ts/src/resolver.rs。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/518323.html
標籤:混帐
