Rendy
Rendy

Reputation: 5698

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!

Upvotes: 13

Views: 15448

Answers (3)

Rendy
Rendy

Reputation: 5698

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

Upvotes: -2

Suracheth Chawla
Suracheth Chawla

Reputation: 1044

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

Upvotes: 36

VonC
VonC

Reputation: 1328712

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

Upvotes: 4

Related Questions