更新时间:2023-12-04 20:57:52
您 可以 执行此操作!方法如下:
You CAN do this! Here's how:
git merge< sha>合并有问题的更改-s我们的
.git merge <sha> -s ours
. git diff< sha> ^.重新应用对工作副本的更改.|git apply
. git checkout -p
可能对您来说很好).git diff <sha>^..<sha> | git apply
.git checkout -p
may work well for you).
这将产生一个具有两个分支的历史记录;一种是删除文件的文件,另一种是从未删除文件的文件.结果,git无需使用诸如 -C -C -C
之类的英雄来跟踪文件的历史记录.(实际上,即使使用 -C -C -C
,该文件也不会还原",因为git看到的是创建了一个新文件作为副本之前存在的文件.通过这种技术,您可以将同一文件重新引入到存储库中.)
This produces a history with two branches; one in which the file was deleted, and one in which it was never deleted. As a result, git is able to track the file history without resorting to heroics such as -C -C -C
. (In fact, even with -C -C -C
, the file isn't "restored", because what git sees is that a new file was created as a copy of a previously existing file. With this technique, you are reintroducing the same file to the repository.)