I made a lot of changes (which I should have committed more frequently, I know), and at some point the branch was showing as @372ee52
, now I cannot see any changes as if they were never made.
Is there a way to get those changes? I tried using IntelliJ's local history, but there are way too many changes missing.
I've searched all the commits to find the one with that ID, there is none.
thank you.
EDIT:
to clarify: I committed the changes not realizing the active branch was not main
, then I tried to push, but it failed. After that I can only see the main
branch.
git log shows my older commits but non of those contain the changes I made.
git status shows only the changes I tried to get when using IntelliJ's local history feature.
git branch shows only the main branch.
CodePudding user response:
It sounds like you made some commits when you were in a "detached head" state. The commits were recorded, but they're not associated with any branch. The git reflog
command will show you how the value of HEAD
has changed over time in your local repository; this gives you a history of branch changes, new commits, etc.
Look at the last several entries show by git reflog
and you will probably see the commits you made before switch to the main
branch.
You can create a new branch pointing at the most recent commit in that series by running git branch <branchname> <commit id>
.