How to push 2 branches from local to remote repo in git?

I have 2 branches in my local, for example:

  • FirstApp
  • SecondApp
  • How to push both of them to remote repo? Do I also need to create two branches in remote as well?

    Many thanks!


    You can do it by executing the following command.

    git push [remote name] [branch1] [branch2]

    For example if you want two put branch FirstApp and branch SecondApp to the remote origin, you can execute

    git push origin FirstApp SecondApp
    

    If you want push more branches, just add the branch name that need to be pushed to the end.

    For more information about git. You can checkout this book from the following link - http://git-scm.com/book


    With recent change in the default push policy , I would advise:

     git push -u origin FirstApp
     git push -u origin SecondApp
    

    That way, even with the new 'simple' policy, it will push and create an upstream branch named after your local branches.

    Now keep in mind that if you clone back your remote repo, it will not create local branches for all the remote branches : see "Track all remote git branches as local branches".

    To see if your branches were pushed after a new clone, check out the result of:

    git branch -a
    

    Now I use SourceTree to help managing my local repository.

    It helps to push all local branches that have not been created at repo by:

  • Press Push button on top bar
  • Check the Push and Track columns for each branches that have not been pushed to remote
  • Press Ok button
  • 链接地址: http://www.djcxy.com/p/4448.html

    上一篇: git浅克隆(克隆

    下一篇: 如何在git中将2个分支从本地推到远程回购?