Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting git branch to GitHub fork

I came to git via terminal, not GitHub and I am wondering how I make a connection between the two.

From a checkout I have, I created a branch in terminal by running this command: git checkout -b newbranchname

From my understanding, GitHub calls this "forking". How do I connect the branch on my box to a fork of a checkout on GitHub?

(Thanks ahead of time for your help. My background is about 1.5 years of subversion.)

like image 931
jackiekazil Avatar asked Jul 17 '10 22:07

jackiekazil


1 Answers

You're mixing a few things up.

First of all, a checkout in SVN is not the same as a checkout in git. What is called a checkout in SVN is called a clone in git. You don't check out a repository, you clone it. "Checking out" means switching to a specific branch, which is more or less the same as svn switch, but you also have the ability of creating a new branch in the same step (that's what -b does).

So I'm assuming that you have been using git locally, have now created a project on github and would like to push your changes to the github repo.

A fork is a copy of an existing third party repo on github. You can hit the "fork" button to get your own copy of that repository, allowing you to make your own changes. The other person can then pull in any changes you make into his own repository.

To associate your github repo with your local repo you do (locally):

git remote add origin [email protected]:<username>/<repo>.git

To push your changes:

git push origin master

You can find some great documentation for git here: http://git-scm.com/documentation

like image 101
igorw Avatar answered Oct 05 '22 11:10

igorw