How to view the git history of a project and revert to an older commit?
I am new to open source and git. I have been learning git and contributing to a project. I have been assigned the task of looking into its git history at past commits and learning from the code then (since the project has evolved now). I know that git stores the entire history of the project. So is there a way to revert to an older version of the project locally. I don't intend to or have rights to revert its remote repo back in time, I just want to revert my local copy to an older commit.
gitk shows a graphical history of commits, each with a unique SHA hash indentifier.
You can checkout to an earlier version using git checkout {commit id}. You make Git revert to an earlier version using these commands:
# 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
Revert to a commit by a SHA hash in Git?
sounds like you should use "git reset" instead of "git revert" to delete recent changes and reset to a former commit.
to list previous commits you may use git log
then once you have found the commit you want to revert to, use the first 9 characters of that commits SHA in the git reset cmd like: git reset --hard fbcc6aa00
链接地址: http://www.djcxy.com/p/18842.html上一篇: 理解`git reset