1

I am using git-review with Gerrit for code review.

I just came across a pretty serious problem when using this tool: I lost my changes.

Here is what I did:

  • added files with git add
  • forgot to git commit
  • executed git review --reviewers johndoe

All the added files are now gone, changes lost. git status says nothing is changed.

git review gave me following message:

"No changes between HEAD and origin/master. Submitting for review would be pointless."

How could the changes be lost? Is there a way to revert?

Sagar P. Ghagare
  • 542
  • 2
  • 12
  • 25
Danijel
  • 8,198
  • 18
  • 69
  • 133

1 Answers1

1

Since you've done a git add, Git should still have the blobs for your changed files in its internal structures, although without their filenames. There are ways to recover them, but it will take some patience and forensic work on your part, linking blobs to what file they belong to.

Internal storage of Git objects is documented here: https://git-scm.com/book/en/v2/Git-Internals-Git-Objects

You might be able to recover your changed files using git-recover: https://github.com/ethomson/git-recover

The discussion on this different but related question might help too: What happens if i interrupt git add command?

joanis
  • 10,635
  • 14
  • 30
  • 40