git:冲突后在索引/工作树中存储文件的不同阶段

Oli*_*ier 5 git conflict git-add

假设一个文件与git处于冲突状态.

这意味着索引包含3个版本的文件,前一个,一个来自一个分支,另一个来自另一个分支.

我想在工作目录中查看版本3("他们的"),并在索引中查看版本2("我们的").

有没有一种无痛的方法可以做到这一点?

CB *_*ley 4

也许最无痛苦的方法就是这样。

# Checkout 'their' version from the index into the working tree
git checkout --theirs file

# reset the index to the HEAD version, i.e 'our' branch
git reset HEAD file
Run Code Online (Sandbox Code Playgroud)

除非您丢失了(可以这么说),update-index否则不需要用管道来摆弄索引。HEAD