[SOLVED] github desktop cannot publish detached head lost changes

Hallo,

yesterday i worked all the day on some php code.

Today i tried to put the new code in the repository and push on the web.

On Github desktop, i committed the changes but when i tried to push i got the error:

github desktop cannot publish detached head lost changes

I googled for this problem but wasn’t able to find something interesting.

Then i just clicked on current branch -> master… and all my changes disappeared from the code folder!

No warnings or confirmation requests…

Is there a way to retreave my work?

Thanks a lot,

G.V.

[EDIT]

I found the solution myself:

in CLI tape 

git reflog

In my case, the output was:

7d1c718 (HEAD -> master, origin/master, origin/HEAD) HEAD@{0}: reset: moving to HEAD
7d1c718 (HEAD -> master, origin/master, origin/HEAD) HEAD@{1}: checkout: moving from f4c53154862813b4d536e29164a8bc97bc9a8c57 to master
f4c5315 HEAD@{2}: commit: inizializzazione dubug phpstorm
69bda05 HEAD@{3}: checkout: moving from master to 69bda057bfffc0b93ae58f0c4cb4e3d7809ba5d4
69bda05 HEAD@{4}: reset: moving to 69bda057bfffc0b93ae58f0c4cb4e3d7809ba5d4
2cf8a49 HEAD@{5}: revert: Revert “pre collegamento db pratiche”
5d16dd3 HEAD@{6}: revert: Revert “Revert “pre collegamento db pratiche””
51cb9f3 HEAD@{7}: revert: Revert “pre collegamento db pratiche”
69bda05 HEAD@{8}: reset: moving to 69bda057bfffc0b93ae58f0c4cb4e3d7809ba5d4
7d1c718 (HEAD -> master, origin/master, origin/HEAD) HEAD@{9}: revert: Revert “pre collegamento db pratiche”
b9ddc64 HEAD@{10}: revert: Revert “Revert “pre collegamento db pratiche””
ce08bf1 HEAD@{11}: revert: Revert “pre collegamento db pratiche”
69bda05 HEAD@{12}: commit: pre collegamento db pratiche
46ec292 HEAD@{13}: commit: salvataggio prima modifica nome colonne relazioni
a3bb260 HEAD@{14}: commit: inserimento fakedata doctrine
3fd70fd HEAD@{15}: pull --progress origin: Fast-forward
09cb040 HEAD@{16}: commit: ignored idea
bc0d3db HEAD@{17}: commit: inizio migrazione classi in entita
c113413 HEAD@{18}: pull --progress origin: Fast-forward
dc65fee HEAD@{19}: commit: temp
a1001f9 HEAD@{20}: clone: from https://github.com/cavigliera/fgcweb.git

then i executed the command:

git branch recover-branch f4c53154862813b4d536e29164a8bc97bc9a8c57

where

  • recover-branch is the name of the new branch we’ll create for recover

- f4c53154862813b4d536e29164a8bc97bc9a8c57 is the sha on the output of “git reflog”.

Then i went on my ide, selected the new branch and recovered the last commit.

Hope this will help someone!

1 Like

Hi @cavigliera, Thanks for coming back to share what worked for you. We’re looking forward to seeing you around!

1 Like