How do you push just a single Git branch (and no other branches)?

后端 未结 4 2033
独厮守ぢ
独厮守ぢ 2020-12-02 03:37

I am working on a local git repository. There are two branches, master and feature_x.

I want to push feature_x to the remote r

4条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-02 04:22

    So let's say you have a local branch foo, a remote called origin and a remote branch origin/master.

    To push the contents of foo to origin/master, you first need to set its upstream:

    git checkout foo
    git branch -u origin/master
    

    Then you can push to this branch using:

    git push origin HEAD:master
    

    In the last command you can add --force to replace the entire history of origin/master with that of foo.

提交回复
热议问题