2

I aborted rebase and lost all the work, I had not commited anything else that what I can recover from the repo. That is, I made a commit yesterday and pushed to a branch, kept on working until today without commiting any new work, and aborted the rebase.

I tried git reflog as suggested in this answer and there is HEAD@{0}: rebase: updating HEAD and there are HEAD@{1}: ... HEAD@{7}:

Since I hadn't commited any work, did I loose it permanently? Also, the branch in which I was switched when aborting rebase

Is there a way to got to right before the abort rebase?

Thank you

user3808307
  • 735
  • 3
  • 18
  • 45
  • I was under the impression that you can't rebase if you have unstaged changes. – astrochun May 08 '21 at 23:23
  • Are you sure you didn't do a `git stash`? Try `git stash list`. If you see something that resembles WIP try `git stash pop` or `git stash apply`. – astrochun May 08 '21 at 23:24
  • 1
    What OS are you using? What version of Git? What does `git rebase.autostash` return? – VonC May 08 '21 at 23:25
  • @astrochun I am in Android Studio and clicked a button that said abort rebase, I have no idea what it did. Now I also see that it switch me to a different branch – user3808307 May 08 '21 at 23:26
  • "I made a commit yesterday and pushed to a branch" then you can recover that commit. – matt May 08 '21 at 23:27
  • @matt yes, I worked from yesterday until today, I want to recover the work from yesterday until today, that is what the question is about – user3808307 May 08 '21 at 23:28
  • @VonC I am in linux mint. The command returns git: 'rebase.autostash' is not a git command. See 'git --help'. – user3808307 May 08 '21 at 23:29
  • 1
    @user3808307 I meant `git config rebase.autostash` – VonC May 08 '21 at 23:34
  • I wouldn't count on it. Git saves commits. That is all it saves. Only commits can be recovered. I do not know what you were rebasing or why but I would assume that whatever is not committed is lost. – matt May 08 '21 at 23:36
  • @user3808307 On Linux Mint, check if Timeshift is active (https://community.linuxmint.com/software/view/timeshift) – VonC May 08 '21 at 23:38
  • @VonC it doesn't return anything. I also have now (cause I've been messing around trying to fix this) HEAD@{2}: rebase: updating HEAD So I reset hard to HEAD@{2} but it didn't work – user3808307 May 08 '21 at 23:39
  • If by any chance you _added_ those files that you had been worked on at a point in time, they are dangling objects in the DB. https://stackoverflow.com/questions/9560184/recover-dangling-blobs-in-git – eftshift0 May 08 '21 at 23:43
  • 1
    @user3808307 I always activate `rebase.autostash` (https://stackoverflow.com/a/24114760/6309), that way I don't loose any work in progress in case of rebase. If not, any file not added to the index, and not committed... would be gone. – VonC May 08 '21 at 23:44
  • @VonC: rebase without autostash should refuse to start if there is uncommitted work. (Emphasis, perhaps, on "should" here? ) – torek May 09 '21 at 07:40
  • @torek I suspect rebase can start if the files are new ones, not involved in the rebased files. But aborting a rebase seems to involve a clean of the working tree. Not sure though, since I have always worked with `rebase.autostash true`. – VonC May 09 '21 at 08:06

1 Answers1

1

To summarize:

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283