Reputation: 20919
I have a revision like A -> B -> C -> D -> E
. I tried to rollback to C
and commit that as a new revision F
but it seems it's not the right way to do it: I git checkout C
and then do some changes and then git commit
. However, when I git push origin HEAD
it complains that:
error: unable to push to unqualified destination: HEAD
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
As this SO question suggests, I tried git fetch -p origin
but it didn't work. Still got the same error message.
My question is that how can I get rid of this situation and fulfill my original goal (rollback to C
and commit that to F
)?
Also, as this question suggests, I can:
git rm -r .
git checkout HEAD~3 .
git commit
but I don't really want to git rm -r .
because there are a lot of untracked but useful stuff.
Upvotes: 4
Views: 5339
Reputation: 225052
It sounds like you're looking for git revert
. In your case:
git revert E D
Afterwards you can rebase to squash the two reverting commits together.
Upvotes: 2