Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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!

like image 367
Rendy Avatar asked Jan 21 '13 02:01

Rendy


2 Answers

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

like image 159
Suracheth Chawla Avatar answered Nov 05 '22 22:11

Suracheth Chawla


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
like image 32
VonC Avatar answered Nov 05 '22 22:11

VonC