How to force push to another branch in Git

Forcing is performed by:

git push origin +branch

Clicking on a remote branch with a different name is performed as follows:

git push origin local:remote

How to force push to another named remote branch?

I did my best:

git push origin local:+remote

But he creates a new branch named +remote

+3
source share
2 answers

Just to be more complete than the accepted answer: the syntax for refspec is [+][src][:dst], and not more than one of srcand is :dstomitted (so the empty line and +by themselves are both invalid).

Therefore, the syntax is not --forcefor your case - +local:remoteand not local:+remote.

--force + refspec, .. :

git push --force origin someBranch local:remote anotherBranch
git push origin +someBranch +local:remote +anotherBranch
+3

git push origin local:remote --force

+2

All Articles