Search code examples
gitgithubopen-source

How can I roll back someone's entire project in github to its initial state after forking it to my local drive?


Is there way to roll back not every commit but to the very beginning of the project? Then I want to step forward commit by commit and see what changes the author did?

What is workflow in this case?


Solution

  • git log | tail 
    

    will show the initial commits, each with commit id like below:

    commit e73188b5512c82290a4070af4afddac20d0b981e
    

    then

    git checkout e73188b5512c82290a4070af4afddac20d0b981e
    

    Git will use this commit as its current state, any files before commited will still exist but be considered "untracked" by git. Then you can clean the scene with:

    git clean -fd
    

    This will clean any files not in the commit state, Then you return the the state up to that commit, and through the git log list, you can reach any point you want, by checkout the adjacent commit, you can view the changes. Or you can see the different in git with:

    git diff  commit-id1 commit-id2