How to push 2 branches from local to remote repo in git?
I have 2 branches in my local, for example:
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:
上一篇: git浅克隆(克隆