Search code examples
pushgit-pushgit-remote

What if you make a mistake and push to incorrect repository?


While doing a push, if i put the wrong but valid arbitrary location that is not my remote master repo. Apart from upsetting a lot of people what other damage to the repo will it do? Is there a way to safeguard against this?


Solution

  • If you succeeded in pushing your branch, then I would assume that the branch did not yet exist there, and you simply created an unwanted/unneeded remote branch there. I suppose there is a slight chance that you somehow managed to fast-forward a branch by the same name in another repo, but this would be a real edge case, and not something I would expect to happen.

    Of course, if a branch by the same name already existed then most likely your push would have been rejected. If the branch already existed on the other repo, then this is the case I would be more concerned with. Fortunately Git would likely block a mistaken push in this case.