I decided to go back a few commits because the path I followed was wrong. So I checked out Added cordova to .gitignore
commit, and made some modifications. Like illustrated below :
Now when I push the new modifications, an error message shows up :error: src refspec (detached from aad6423) does not match any.
How can I tell git to discard the previous commits (in purple) and continue with my local HEAD as master ?
the HEAD is not stepping onto any branch, then above commands do: checkout the target commit (you're already stepping there, but just in case) move master pointer to that commit (no problem, since it is a forward move) checkout master branch in order to be stepping onto it (for future commits)
Make HEAD your new local master
:
$ git checkout -B master
Force-push your changes:
$ git push -f
Even though you don't want that old branch anymore, git really doesn't like rewriting history or discarding changes. Just revert and merge.
git branch new_master # name current detached HEAD
git checkout master # switch back to master
git revert --no-edit HEAD~4..HEAD # create commits reverting back to where the history split
git merge new_master # merge
git branch -d new_master # don't need it anymore
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