How to view git project history and revert to an older commit?

I am new to open source and git. I studied git and contributed to the project. I was instructed to look into her git history in the past, and then learn from the code (since the project has evolved now). I know that git keeps the entire history of the project. So there is a way to return to the old version of the project locally. I do not intend or do not have the right to return my remote repo on time, I just want to return my local copy to an older commit.

+1
git
source share
2 answers

gitk shows a graphical history of commits, each with a unique SHA hash index.

You can check to an earlier version with git checkout {commit id}. You make git revert to an earlier version with the following 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 

Return to commit with SHA hash in Git?

+4
source share

it sounds like you should use "git reset" instead of "git revert" to remove the latest changes and reset to the previous commit.

to list previous commits you can use git log commit ss

then after you find the commit you want to return to, use the first 9 characters of what SHA does in git reset cmd, for example: git reset --hard fbcc6aa00

0
source share

All Articles