How to overwrite remote branch with different local branch with git

You can use the local-name:remote-name syntax for git push:

git push origin newBranch:oldBranch

This pushes newBranch, but using the name oldBranch on origin.

Because oldBranch probably already exists, you have to force it:

git push origin +newBranch:oldBranch

(I prefer the + instead of -f, but -f will work, too)

To delete a branch on the remote side, push an “empty branch” like so:

git push origin :deleteMe

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)