nonopolarity
nonopolarity

Reputation: 151076

Using Git, if some commits are lost, how to view it or get it back?

While experimenting with Git, I changed a file's content from 1 to 100, and was able to commit and see it in the log. But after some more test and

git checkout <some_hash>      // I think this is to revert the whole repo to a 
                              //     certain state

git checkout master           // And this is to change the repo to the most 
                              //     current state

the commit histories were lost in git log. What happened -- could the commit have gone into another branch and how to view it or get it back?

Upvotes: 1

Views: 76

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 993471

It's hard to say exactly where the commit went without knowing exactly what you did. However, the git reflog command will show the positions that the current branch head has been in the past, including commits that may no longer be in the history.

Upvotes: 4

Related Questions