The code I have been writing for 5 days disappered after tapping wrong button. I have been working in HEAD. And made 3 commits in 5 days. In BitBucket desktop app I have twice tapped a different branch and now its gone. I can't find commits that were not sent to the server.
The branch doesn't come up, but commits are visible in history:
Macintosh:repo admin$ git branch -a
* HEAD
master
remotes/origin/HEAD -> origin/master
remotes/origin/master
Macintosh:repo admin$ git branch
* HEAD
master
Here is the history of commits:
Macintosh:repo admin$ git log --oneline --all --graph --decorate $(git reflog | awk '{print $1}')
warning: refname 'HEAD' is ambiguous.
* 1d2bc57 THIRD
* d2a0291 SECOND
* 40c2d66 FIRST
| * 7100271 (HEAD -> master, origin/master, origin/HEAD, HEAD) CURRENT
|/
* bc35e2f OLDCOMMINT
The Desktop app shows empty HEAD branch, thats why I can't understand what is going on here. How do I switch from "7100271" (CURRENT) to "1d2bc57" (THIRD) ?
Thanks in advance.
You should be able to access the data by simply using git checkout on the commit sha
git checkout 1d2bc57
After this you may not be on any branch (a 'detached head state') anymore, in which case you can just create a new branch.
git checkout -b newBranch
I hope this helps!