我正在合并代码,当我本想执行 git checkout --ours my_file
命令时,不小心输入成了 git checkout --theirs my_file
命令。
是否有方法来撤销此操作?
我正在合并代码,当我本想执行 git checkout --ours my_file
命令时,不小心输入成了 git checkout --theirs my_file
命令。
是否有方法来撤销此操作?
TL;DR: 只需使用git checkout --ours my_file
如@matt在评论中提出的建议,您可以使用git checkout <version> -- my_file
检出所需的特定版本。
最简单的方法实际上是输入第二个命令git checkout --ours my_file
,因为--ours
和--theirs
是基本分支和合并分支的引用。 因此,它基本上就像@matt的解决方案,但引用更简单。
git checkout <version> -- my_file
就解决了问题。 - Ulysse BN