How do you create a remote Git branch?

后端 未结 23 1942
感情败类
感情败类 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条回答
  •  难免孤独
    2020-11-22 14:10

    If you want to create a branch from the current branch

    git checkout -b {your_local_branch_name} 
    

    you want a branch from a remote branch, you can try

    git checkout -b {your_local_branch_name} origin/
    

    If you are done with changes you can add the file.

    git add -A or git add 
    

    Then do a commit locally

    git commit -m 'your commit message'
    

    When you want to push to remote repo

    git push -u origin 
    

    All together will be

    git checkout -b bug_fixes 
    

    or If you want to create a branch from a remote branch say development

    git checkout -b bug_fixes origin/development

    You can push to the branch to remote repo by

    git push -u origin bug_fixes
    

    Anytime you want to update your branch from any other branch say master.

    git pull origin master.

提交回复
热议问题