Recovery after accidental `git am` and `git am --abort`

295 views Asked by At

Since I 'm heavily using ap as alias for git add --patch, I accidentally typed git am instead. OK, I thought, I hope I can just git am --abort.

But to my horror, it turns out that at some point, git am, without any warnings, does a hard reset on your uncommited and unstaged work. Provided that before my ap I'm most likely to have unstaged changes, this typo always means loss of data.

Actually it happened to me few times, but now it really hurt, since there was quite a lot of work.

For comparison, it happens to me normally that e.g. rebase or checkout bails out when I have unstaged changes. Why would am be different (ignorant/destructive)?

Can I recover my unstaged changes after this?

1

There are 1 answers

2
Oliver Matthews On

Sorry, if they were unstaged then they were just ordinary files whose contents are outside of git's view. Unless your filesystem has some form of continuous data protection setup (git annex?) setup in it, I think you are out of luck. Possibly it's time to alias am to something else.