如何使用git将指定文件还原到版本之前?

时间:2018-04-01 07:54:02

标签: git github

如何将指定文件还原到版本之前?例如:(下一行是后一段时间)

commitIDa create main.go and other operations
commitIDb modify main.go to content1 and other operations
...... (may be a lot of logs)
commitIDc modify main.go to content2 and other operations
commitIDd ??????(my demand is following:)

现在,我希望文件main.go内容还原commitIDb,而其日志仅限:

commitIDa
commitIDb

除文件main.go外,其他操作文件可能包含以下日志:

commitIDa
commitIDb
...
commitIDc
commitIDd

换句话说,我想从(...)和commitIDc

中删除main.go日志信息

然后我可以git推送到远程原点

reset-or-revert-a-specific-file-to-a-specific-revision-using-git无法正常工作。我的问题与此不同。因为它将提交新的commitID,并且其内容与之前的内容相同。

我的问题的核心区别是:main.go日志只是commitIDa commitIDb,没有新的commitID要提交。换句话说,它从commitIDb

之后的日志中删除了main.go日志

0 个答案:

没有答案