1

Suppose I have five modified files, and I stage two of them for commit (let's call this commit A). Then I still have three uncommitted changes which are left for future commits. Now suppose sometime in the future I decide to revert my working directory to commit A, what would be state of the files that were not staged for commit into A, but were modified nonetheless. Would those changes be lost?

4

2 回答 2

2

Agit revert只会修改commitA您正在还原的文件。
它不会触及任何其他文件。

话虽如此,隐藏这些文件可能是个好主意,只是为了确保 ( git stash) 在任何“出错”的情况下不会发生任何事情。

于 2014-09-21T12:38:35.230 回答
1

无论您当前的暂存情况如何,提交“A”的“还原”只会在顶部创建一个新提交(例如 A*),这会反转提交 A 的影响。您需要使用以下命令开始还原过程一个干净的工作目录(即存储或提交您修改/暂存的文件)。

于 2014-09-21T12:41:11.093 回答