user2921643 user2921643 - 1 year ago 93
Git Question

Conflicts after git reset --hard

I've got a branch named

and I want to reset all changes made on this branch. Need to move all commits from branch named
So this is what I did (on branch

git fetch -all
git reset --hard origin/d
git clean -f -d
git push origin master --force

I've got following message:

remote: error: denying non-fast-forward refs/heads/master (you should pull first)

But I don't want to pull, I just want move all commits from branch
to branch
(ignoring all local/non-local commits on branch

When I put
git pull
I've got many conflicts that I do not want to resolve. Could anyone help me and tell me what is the simplest way to do that?

Answer Source

The error message indicates that (1) your server is disallowing forced updates (the --force argument), and (2) for some reason Git wants to push m to master.

To temporarily work around the second issue, you can do:

git push origin m:refs/heads/m --force-with-lease

(It's better to use --force-with-lease rather than --force, because the former will only overwrite if your remote-tracking branch is up-to-date. If someone else happened to push commits since you last fetched, then --force will overwrite those, causing work to be lost.)

However, if your server is disallowing forced updates, then it will probably reject that command as well. If you have admin access to your server, then one option is to change that. Otherwise, to work around that, you should be able to delete the branch and then push:

git push origin --delete m
git push origin m:refs/heads/m
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download