Activity 7b: Clone your GitHub repo locally
Activity 8b: Clone your GitHub repo locally
So far you’ve been working with GitHub in the browser. Now we’ll take the same content and work with it locally. This is what makes the GitHub wiki unique from other wikis — it’s a Git repo, so you can manipulate the content the same way as any other Git repo (working locally, pushing, pulling, merging, branching, etc.).
To clone the GitHub repo locally:
- If you don’t already have Git installed, set it up on your computer. (You can check whether Git is installed by typing
git --versionin your terminal or command prompt. See Install Git for more information on installation.)
While viewing your the GitHub wiki in your browser, look for the section that says Clone this wiki locally (highlighted below). Click the clipboard button. (This copies the clone URL to your clipboard.)
The wiki is a separate clone URL than the project’s repository. Make sure you’re viewing your wiki and not your project. The clone URL will include
In contrast to the “Clone this wiki locally” section, the “Clone in Desktop” button launches the GitHub Desktop client and allows you to manage the repository and your modified files, commits, pushes, and pull through the GitHub Desktop client. If you’re interested in using the GitHub Client of the command line, see this other activity: Activity: Use the GitHub Desktop client.
Open your terminal emulator:
- In your terminal, either use the default directory or browse (
cd) to a directory where you want to download your repository.
Type the following, but replace the git URL with your own git URL that you copied earlier (it should be on your clipboard). The command should look something like this:
git clone https://github.com/tomjoht/weatherapi.wiki.git
When you clone a repo, Git will show something like the following:
Cloning into 'weatherapi.wiki'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Compressing objects: 100% (2/2), done. remote: Total 9 (delta 0), reused 0 (delta 0), pack-reused 6 Unpacking objects: 100% (9/9), done.
The folder Git creates in the above example is called
Cloning the wiki gives you a copy of the content on your local machine. Git is distributed version control software, so everyone has their own copy. When you clone the repo, you create a copy on your local machine; the version in the cloud on GitHub is referred to as “origin.” Thus, you have two instances of the content.
More than just copying the files, though, when you clone a repo, you initialize Git in the folder where you clone the repo. Initializing Git means Git will create an invisible Git folder in that directory, and Git can start tracking your edits to the files, providing version control. With Git initialized, you can run
pullcommands to get updates from the online repository (origin) pulled down to your local copy. You can also
commityour changes and then
pushyour changes back up to origin.
Navigate to the directory where you cloned the repo (either using standard ways of browsing for files on your computer or via the terminal with
cd) to see the files you downloaded. For example, type
cd weatherapi.wikiand then
dir(Windows) to see the files.
You don’t need to type the full directory name. Just start typing the first few letters and then press your Tab key to autocomplete the rest.
You might also want to browse to this folder via Finder (Mac) or Explorer (Windows). The folder also continas an invisible folder called
.git. For instructions on making hidden files visible, see one of the following: Windows or Mac).
6/150 pages complete. Only 144 more pages to go.
Want to buy me lunch? Click the Donate button below to donate any amount through Paypal.