When I switch from Develop branch to a previously submitted, the head branch is my current branch,but the branch is not shown in my branch list (CMD: git branch).
When I finished some work,I don't be careful switch directly to Develop branches,oh my God,I lost these changes, how can I find just the part of change?
Use the reflog to find out what happened and then recover to that point
git reflog
You can always use the reflog
as well.
git reflog
will display any change which updated the HEAD
and checking out the desired reflog entry will set the HEAD
back to this commit.
Every time the HEAD is modified there will be a new entry in the reflog
git reflog
git checkout HEAD@{...}
This will get you back to your desired commit
How to find and restore added content (even if it was not commited )
Use the git fsck
to find out about all the lose object (dangling) and then you can check them out with the git cat-file -p <sha-1>
and restore them.