I recently screwed up a git rebase -i
, and so I wanted to do a git reset --hard HEAD@{5}
.
However, doing a git reset --hard HEAD@{5}
or git log HEAD@{5}
caused the following error message to be shown:
fatal: ambiguous argument 'HEAD@{5}': unknown revision or path not in the working tree.
Then, I decided to specify the hash key corresponding to HEAD@{5}
shown in git reflog
instead. For instance:
git reset --hard e8be841
In doing so, was there any risk screwing up the git repository or doing something unexpected?
For me the problem was I needed to put the double quotes on Windows command prompt.
Instead of:
git reset --soft 'HEAD^'
I had to write:
git reset --soft "HEAD^"
Git is very forgiving in how it does merges and rebases. If you look at the git repository's file structure during one of those operations, you will see that it alters files designated to help with those operations and does not unsafely change core objects. If it does, it's in an additive manner.
So there is practically no chance of doing any damage to your repository. As an example, take another repo, make a copy, start a rebase and then compare the .git folders in both.
P.S. as per the comment on your question, yes, do use git rebase --abort
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