I have a local branch work, where I created two new files a.py, b.py and committed them.
Then, instead of doing "git rebase origin/master", I accidently typed "git rebase origin master", and now the commit I did is gone and the files are gone. Does anyone know how I can recover my files?
You can run git rebase --abort to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called. You can run git rebase --skip to completely skip the commit.
Simply take the commits that you want to get rid of and mark them with "d" instead of "pick". Now the commits are deleted effectively undoing the rebase (if you remove only the commits you just got when rebasing).
When you're finished making all your changes, you can run git rebase --continue . As before, Git is showing the commit message for you to edit.
To check out the original <branch> and remove the .git/rebase-apply working files, use the command git rebase --abort instead.
Undoing a git rebase
Git keeps the old refs (until you clean them up). You can switch back to the old refs from before the rebase just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With