Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Branching my own project from github, then pushing it back to github with branches intact

This feels like im missing something obvious, but i've been reading tutorials for 3 days and can't seem to make it happen.

I have a private repo on github. I want to run it as two separate branches. As I understand it, I clone the repo so its on my local machine, then branch it using

git branch newbranch

git checkout newbranch

so far so good. Now i make some changes, commit to newbranch. It seems like I can push this all to my remote repo intact, but I'm having trouble doing it without simply merging it with master, which is not what I want to do. How can I put my branches on github intact?

Is this the correct workflow for doing this? If it is, what am I doing wrong?

like image 596
Vagabond_King Avatar asked Feb 14 '10 21:02

Vagabond_King


2 Answers

Just:

 git push origin mybranch

should be enough; it will push the HEAD of the current branch you are in (not master, but the one you are working on) to a similary named branch. if the remote branch has not the same name, then

git push origin mybranch:remotebranch

git push uses a refspec to specify with what <src> object the <dst> ref in the remote repository is to be updated.

like image 106
VonC Avatar answered Sep 29 '22 23:09

VonC


this will only push the newbranch to origin/newbranch on github:

git push origin newbranch:newbranch
like image 25
Tomas Markauskas Avatar answered Sep 29 '22 22:09

Tomas Markauskas