Reputation: 171
I have several commit in a branch, but I notice that there was something wrong so I return (checkout) to a previous commit, and made some changes and now everything is fine.
But the problem is that I am not able to push because git want me to pull first, but I don't want to, because it will merge and I don't want to.
I just want my current local commit that will be the first or latest commit.
How is this possible?
Upvotes: 3
Views: 3001
Reputation: 1383
Just to turn @quetzalcoatl 's comment into an answer...
git push --force
...will move the HEAD
for the branch in the remote to the current commit, even if that commit is before where the remote HEAD
is currently pointed.
This works for undoing a recent commit even after push
ing it. Use a reset --soft
to move the current HEAD
back, then a push --force
to update the head to the remote.
Upvotes: 1