-1

I had checkout a specific branch on git where I was working. Each time I made some changes, I committed and push them using the command:

git push origin HEAD:master

Today, I deleted the project I was working on from my desktop and tried to clone again the repo with the last code.

When I visited my repo I realized that all the work I was pushing using the command above was not committed. Is there a way to find these files or recover permanently deleted files from my desktop?

I tested some tools (e.g. Stellar, Recuva, Disk Drill, Windows File Recovery, imyfone) without success :(

  • Did you commit the code you were working on? Did you push the commits? – evolutionxbox Apr 27 '22 at 15:09
  • It's very simple. Whatever you committed and pushed is preserved and is therefore present in a new clone. Whatever you did not commit is lost, and whatever you committed but threw away without pushing is lost when you deleted the project. – matt Apr 27 '22 at 15:09
  • I cloned again the repo, but the changes has not been pushed. I repeated the steps I followed to see the exact message of git after pushing my changes to head:master. I receive the following message: hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. Check out this branch and integrate the remote changes hint: (e.g. 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. Thus, I think my changes have been lost :( – George Perid Apr 27 '22 at 15:19
  • Yes, that's correct. When the remote told you that the updates were rejected, that was a message saying that the commits you tried to push were not actually pushed from the local repo to remote repo. And since you deleted the local repo, they don't exist at all. – matt Apr 27 '22 at 15:55

1 Answers1

0

Okay, so it turns out (from a comment of yours) that when you pushed, you got the Updates were rejected message from the server. Well, when the remote told you that the updates were rejected, that was a message saying that the commits you tried to push were not actually pushed from the local repo to remote repo.

So the local repo was the only place where these commits existed. And since you deleted the local repo, they don't exist at all.

matt
  • 515,959
  • 87
  • 875
  • 1,141