0

I entered git checkout ( git number ) and I was thrown to this commit but deleted all the commits made above. Is there a way to return the files

Suggest solutions to the problem

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Cabbage
  • 1
  • 1
  • What was surprising about that? What did you _want_ to happen? `git checkout ` just takes you to that commit. If you want to revert (with the specific meaning of applying a new commit that undoes the changes from a previous commit), [`revert`](https://git-scm.com/docs/git-revert). – jonrsharpe Feb 08 '23 at 18:01
  • 1
    You probably want `git checkout master` – tkausl Feb 08 '23 at 18:02
  • 1
    ...or main, depending on what your default branch is. You might try `git checkout -` first, that will check out the last branch you had checked out. – Jared Smith Feb 08 '23 at 18:02
  • It sounds like you checked out a specific sha1 id, and are now in ["detached head mode"](https://stackoverflow.com/tags/git-detached-head/info) where you no longer see the changes that were made on the branch you had checked out before. In that case the remedy is to check out the branch again. In any case running `git reflog` is a useful tool when trying to recover things that get "lost" by git. And as always, the best visualization tool is `gitk --all`, use it constantly every day (I do, and I started with git in 2005). – hlovdal Feb 08 '23 at 18:10

0 Answers0