0

I have cloned a lecture project from Github. The project is a finalized one and it contains multiple commit history eg: Lecture 1, Lecture2.

Using the software TortoiseGit, I am able to review the log of Git commits. What I am trying to do is that I need to review code of the same project from lecture 1 to lecture 7.

However, if I try to use reset hard/ check out to go back to specific commit, nothing seems to happen. The folders and files do not seem to change.

I read from the Net that using cleanup command could make it work. So I cleaned up. It indeed went back to the old version. However, the commit history after this commit is missing. Then I cannot proceed.

Thank you in advance

Basic Procedures:

Init: at Lecture 7

Operation1 : Go back to Lecture 1

Operation 2: Go to Lecture 2

Operation 3: ....

Operation 7: go back to lecture 7

user8805240
  • 41
  • 1
  • 3
  • 2
    Possible duplicate of [Rollback to an old Git commit in a public repo](https://stackoverflow.com/questions/2007662/rollback-to-an-old-git-commit-in-a-public-repo) – Dimitris Oct 02 '18 at 09:09

1 Answers1

1

You may checkout an earlier commit directly via:

# from your_branch
git checkout <SHA-1 has of earlier commit>

This will put Git into the detached HEAD state, where the HEAD points some earlier commit in the branch, but is not actually on a particular branch. You may poke around and review the code, and when you are finished, return to your original branch via:

git checkout your_branch
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Thank you, but it does not solve my problem. After checkout, nothing happens. The files written after the commit still exist, for example I checkout to Lecture 3, materials in Lecture 7 still exist. It has only 1 master branch and I am working on it. – user8805240 Oct 02 '18 at 18:34