views:

58

answers:

2

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.)

+1  A: 

a/ no, that is not forking.
You have created a branch in your local repo.
You can push it to your GitHub repo, where it will live as a branch.

From the GitHub manual page:

To push a local branch to an established remote, you simply need to use

git push REMOTENAME BRANCHNAME 

If you don’t want to use the same name on the remote branch you can use

git push REMOTENAME LOCALBRANCHNAME:REMOTEBRANCHNAME.

b/ a fork is a repository clone on the GitHub side (which you can in turn clone on your desktop local side)

c/ If you want to compare branches between different forks on the GitHub side (since, again, forks only exist on the GitHub side; on your side, you are just cloning remote repo), you can!
(Well... you can since 2 days ago, July 15th, 2010):
Cross-Repository Compare View: the ability to compare branches across repositories.


Remember that with a DVCS, you have an extra dimension to branching: publication (push/pull from/to a remote repository)

Creating a branch does not mean having it visible for all others on GitHub.
It is just created locally on your own repo. The publication part is left to you.

VonC
+3  A: 

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

igorw
Your answer is more oriented to helping SVN users than my answer. +1
VonC
Thank you so much for the clarification. I appreciate your help!
jakopanda