Search code examples
gitgit-remote

git: how to restore remote master?


Locally I was working on the master. Then I accidentally did git push origin master instead of git push origin develop:master

What is the best way to restore the master on remote?


Solution

  • You can simply do

    git push -f origin develop:master
    

    to replace the master branch on the server with your develop branch, assuming that you have all commits that should be included in your local clone.

    If someone else might have committed in the meantime, the easiest way is to ask them to push their last push again, so you can fetch, merge and push your changes.