How do I push a new local branch to a remote Git repository and track it too?

后端 未结 15 1588
逝去的感伤
逝去的感伤 2020-11-22 09:17

I want to be able to do the following:

  1. Create a local branch based on some other (remote or local) branch (via git branch or git checkout

15条回答
  •  礼貌的吻别
    2020-11-22 09:52

    You can do it in 2 steeps:

    1. Use the checkout for create the local branch:

    git checkout -b yourBranchName
    

    Work with your Branch as you want.

    2. Use the push command to autocreate the branch and send the code to the remote repository:

    git push -u origin yourBanchName
    

    There are mutiple ways to do this but I think that this way is really simple.

提交回复
热议问题