如何查看项目的git历史并恢复到较旧的提交?

我是开源和Git的新手。 我一直在学习git并为项目做出贡献。 我已经被赋予了在过去的提交中研究它的git历史的任务,然后从代码中学习(因为该项目现在已经发展)。 我知道git存储了整个项目的历史。 那么有没有办法在本地恢复到旧版本的项目。 我不打算或有权及时恢复其远程回购,我只想将本地副本恢复到较旧的提交。


gitk显示提交的图形历史记录,每个提交都有一个唯一的SHA哈希标识符。

你可以使用git checkout {commit id}签出更早的版本。 你使用这些命令让Git恢复到早期版本:

# reset the index to the desired tree
git reset 56e05fced

# move the branch pointer back to the previous HEAD
git reset --soft HEAD@{1}

git commit -m "Revert to 56e05fced"

# Update working copy to reflect the new commit
git reset --hard

在Git中恢复由SHA哈希提交?


听起来你应该使用“git reset”而不是“git revert”来删除最近的更改并重置为以前的提交。

列出以前的提交你可以使用git log 提交ss

那么一旦你找到了你想要恢复的提交,使用在git reset cmd中提交SHA的前9个字符:git reset --hard fbcc6aa00

链接地址: http://www.djcxy.com/p/18841.html

上一篇: How to view the git history of a project and revert to an older commit?

下一篇: Rollback GIT on TFS