标签云

微信群

扫码加入我们

WeChat QR Code


git reset --hard aabb3434 / git push origin branch --force

2018年09月24日40分41秒

git reset without the --hard option resets the commit history but not the files. With the --hard option also files in working tree are reset.

2018年09月24日40分41秒

If you wish to commit that state, so remote repository also points to rolled back commit do: git push <reponame> -f

2018年09月25日40分41秒

MariuszNowak after doing git reset --hard <commit-id>, ( 2 back ) when doing "git push -f origin master" I get "remote: error: denying non-fast-forward refs/heads/master (you should pull first)" it is my repo and I want to take it back :)

2018年09月24日40分41秒

peterk try --force at the end of your git push command

2018年09月24日40分41秒

Make sure you specify the branch name as well.

2018年09月24日40分41秒

Thanks - might not have been what the poster asked for, but much less anxiety-inducing for me.

2018年09月24日40分41秒

Dealing with a remote repository (such as Github), you may have to do a 'git push -f origin master' because of the non-fastforwards to get master to look like it did at the specified commit, but this method is much cleaner than reset.

2018年09月24日40分41秒

kauppi - wouldnt you then have issues pushing back to a remote repo?

2018年09月24日40分41秒

Im dancing in my "how do I fix all my problems" chair.

2018年09月24日40分41秒

Oops, that should be git branch --set-upstream master <remote>/<branch> and git branch --set-upstream crazyexperiment <remote>/<branch>

2018年09月25日40分41秒

no workee when server (stash) disallows force on push. Cannot reset back there.

2018年09月25日40分41秒