Here’s what I did..
- I checked out a previous commit (2 commits ago)
- I modified files
- Committed those files
- Accidentally went back to the master branch
How do I get back to the files I committed without knowing the commit id ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can look at the reflog for HEAD. Two ways of doing so:
git reflog show HEAD(manpage)./git/logs/HEADThis will show you the commits that you recently made, no matter what branch (or lack thereof) they are in.
Suppose you found the lost commit and its hash is
0123ab. You can either checkout it (git checkout 0123ab), or your can merge it into master (git checkout master;git merge 0123ab).