How do I properly force a Git push?

前端 未结 8 2243
一生所求
一生所求 2020-11-22 14:25

I\'ve set up a remote non-bare \"main\" repo and cloned it to my computer. I made some local changes, updated my local repository, and pushed the changes back to my remote r

8条回答
  •  梦谈多话
    2020-11-22 15:01

    Just do:

    git push origin  --force
    

    or if you have a specific repo:

    git push https://git.... --force
    

    This will delete your previous commit(s) and push your current one.

    It may not be proper, but if anyone stumbles upon this page, thought they might want a simple solution...

    Short flag

    Also note that -f is short for --force, so

    git push origin  -f
    

    will also work.

提交回复
热议问题