I was working in the master branch and didn't realize it. I have hours of work that I did in that branch.
When I had finished what I wanted to commit, I went to GitHub Desktop v2.2.3 and noticed that I was in master. Before I had added them to staging, I listed the available branches and picked the one I wanted; it asked me what I wanted to do with the current changes, and I chose an option that said I wanted to "bring them with me".
Now I can't find my changes in either branch.
I went to the command line and entered "git reflog" and get the following:
e328567 (HEAD -> master, origin/master, origin/HEAD, origin/branchNumberOne, branchNumberOne) HEAD@{0}: checkout: moving from branchNumberOne to master
e328567 (HEAD -> master, origin/master, origin/HEAD, origin/branchNumberOne, branchNumberOne) HEAD@{1}: checkout: moving from master to branchNumberOne
e328567 (HEAD -> master, origin/master, origin/HEAD, origin/branchNumberOne, branchNumberOne) HEAD@{2}: reset: moving to HEAD
e328567 (HEAD -> master, origin/master, origin/HEAD, origin/branchNumberOne, branchNumberOne) HEAD@{3}: clone: from https://gitlab.myURL.com/aCompany/myProject.git
I'm not even sure which HEAD index to use to try to get my changes back; how do I figure that out? Or is there another way to recover the changes?
Switching branches does not require a clean index and working tree (i.e. no differences compared to HEAD ). The operation is aborted however if the operation leads to loss of local changes, unless told otherwise with --discard-changes or --merge .
The "restore" command helps to unstage or even discard uncommitted local changes. On the one hand, the command can be used to undo the effects of git add and unstage changes you have previously added to the Staging Area.
A deleted Git branch can be restored at any time, regardless of when it was deleted. Open your repo on the web and select the Branches view. Search for the exact branch name using the Search all branches box in the upper right. Click the link to Search for exact match in deleted branches.
Last time that happened to me IntelliJ saved my day, if you use any IDE you can undo changes on files you lost. Either by doing "undo" or using file history feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With