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 to a remote repo? Do I need to also create two branches remotely?

Thank you very much!

+4
source share
3 answers

You can do this by running the following command.

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

For example, if you want the two FirstApp branches and the SecondApp branch to be removed, you can do

git push origin FirstApp SecondApp 

If you want to push more branches, just add the name of the branch you want to push to the end.

More on git. You can check out this book at the following link - http://git-scm.com/book

+12
source

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

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

Thus, even with the new β€œsimple” policy, it will promote and create an upstream branch named after your local branches.

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

To find out if your branches were pressed after a new clone, check the result:

 git branch -a 
+1
source

Now I am using SourceTree to manage my local repository.

This helps push all local branches that were not created during the repo:

  • Click the button on the top panel.
  • Check the Push and Track columns for all branches that have not been pressed on the remote
  • Click Ok
0
source

All Articles