Changes

Jump to: navigation, search

DPS909 & OSD600 Winter 2017 - Git Walkthrough 2

1,694 bytes added, 12:37, 12 January 2017
Step 3: Cloning a Forked Repository
===Step 3: Cloning a Forked Repository===
Now that we have a forked copy of the [https://github.com/octocat/Spoon-Knife Spoon-Knife] repository, let's '''clone''' it to our local computer. In order to clone a Github repository, we need an appropriate URL. NOTE: this is '''not''' the URL we use to access the repository in our web browser. Rather, we need a git URL.
 
Github provides git URLs using various protocols. The one we'll use most often is the [https://help.github.com/articles/which-remote-url-should-i-use/#cloning-with-ssh-urls SSH URL]. To get an SSH URL for a Github repository, you need to have the appropriate rights (i.e., both read and write permissions). Every repository that you fork will automatically have these rights.
 
In my case, the URL I need is <code>git@github.com:humphd/Spoon-Knife.git</code>, and for you it will be <code>git@github.com:{your-github-username}/Spoon-Knife.git</code>. Using this SSH URL we can clone the repo locally:
 
<pre>
$ git clone git@github.com:humphd/Spoon-Knife.git
Cloning into 'Spoon-Knife'...
remote: Counting objects: 16, done.
remote: Total 16 (delta 0), reused 0 (delta 0), pack-reused 16
Receiving objects: 100% (16/16), done.
Resolving deltas: 100% (3/3), done.
</pre>
 
This did a few things:
 
# created a directory <code>./Spoon-Knife/</code>
# created a <code>.git/</code> database folder in <code>./Spoon-Knife/.git</code>
# downloaded all commits in the forked repo from Github, saving them to our <code>./Spoon-Knife/.git</code> database
# created remote tracking for the <code>origin</code> repository (i.e., our forked repo on Github, from which we cloned)
# checked-out the latest version of the code to our <code>./Spoon-Knife/</code> working directory

Navigation menu