How do you create a remote Git branch?

后端 未结 23 2154
感情败类
感情败类 2020-11-22 13:31

I created a local branch which I want to \'push\' upstream. There is a similar question here on Stack Overflow on how to track a newly created remote branch.

Howeve

23条回答
  •  旧时难觅i
    2020-11-22 14:17

    Create the branch on your local machine and switch in this branch :

    $ git checkout -b [name_of_your_new_branch]
    

    Push the branch on github :

    $ git push origin [name_of_your_new_branch]
    

    When you want to commit something in your branch, be sure to be in your branch.

    You can see all branches created by using :

    $ git branch
    

    Which will show :

    * approval_messages
      master
      master_clean
    

    Add a new remote for your branch :

    $ git remote add [name_of_your_remote] 
    

    Push changes from your commit into your branch :

    $ git push origin [name_of_your_remote]
    

    Update your branch when the original branch from official repository has been updated :

    $ git fetch [name_of_your_remote]
    

    Then you need to apply to merge changes, if your branch is derivated from develop you need to do :

    $ git merge [name_of_your_remote]/develop
    

    Delete a branch on your local filesystem :

    $ git branch -d [name_of_your_new_branch]
    

    To force the deletion of local branch on your filesystem :

    $ git branch -D [name_of_your_new_branch]
    

    Delete the branch on github :

    $ git push origin :[name_of_your_new_branch]
    

    Here All Information

    Other Existing project

提交回复
热议问题