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.
Asked
Active
Viewed 2,420 times
2 Answers
4
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
-
`git log` or `git log --graph` will show a commit history, too. – Christoph Winkler Mar 21 '12 at 13:41
0
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

Duan Walker
- 305
- 1
- 11