Push a specific object to a remote branch

suggest change

General syntax

git push <remotename> <object>:<remotebranchname>

Example

git push origin master:wip-yourname

Will push your master branch to the wip-yourname branch of origin (most of the time, the repository you cloned from).


Delete remote branch

Deleting the remote branch is the equivalent of pushing an empty object to it.

git push <remotename> :<remotebranchname>

Example

git push origin :wip-yourname

Will delete the remote branch wip-yourname

Instead of the colon, you can use --delete, which is easier to read in some cases.

Example

git push origin --delete wip-yourname

Push a single commit

To move a remote branch to one commit without pushing later commits on your local branch, push that commit. Ancestors of the commit are sent if the remote does not already have them. Later commits on the local branch are not.

git push <remotename> <commit SHA>:<remotebranchname>

Example

Assuming a git history like this

eeb32bc Commit 1 - already pushed
347d700 Commit 2 - want to push
e539af8 Commit 3 - only local
5d339db Commit 4 - only local

to push only commit 347d700 to remote master use the following command

git push origin 347d700:master

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents