Yes, if you remember the hash you can get back to it. You might want to use git checkout
or git branch
rather than git reset
, though. You're right that git cleans up occasionally - you'll see it when it happens, because you'll get some messages about "garbage collecting."
To be safe, you can keep a branch pointing at your old commit, and then you'll be able to access it symbolically rather than by remembering the hash.
If you need to find an old hash, but you don't remember it, git reflog
can help you find it. You can also do tricks like:
git checkout @{yesterday.at.3.pm}
If you know roughly the time you want to go back to.