how to undo "git checkout" of a specific commit and return to the last commit I made before checkout

1

I need to go back to the environment that was before I performed git checkout id_commit but when I run git log no longer appear the commits that I performed after the checkout . In the remote repository are all the push push I gave, how can I leave the local repository equal to the remote repository and return to the last commit I gave?

    
asked by anonymous 11.04.2018 / 17:53

1 answer

4

Try using git reflog . You should have a listing like:

220981e HEAD@{0}: checkout: moving from master to 220981e
239b47a HEAD@{1}: checkout: moving from c_api to master

This indicates that in the last checkout I was in the branch master I went to commit 220981e. To get back to where I was.

git checkout master
    
11.04.2018 / 18:07