Linking a Repository to GitHub

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In Git, the command for working with remote repositories is git remote. A local repository can have multiple remote repositories. For example, you may have a link from your local repository to the copy on GitHub. At the same time, you may also have a link from your local repository to a testing server or even a friend’s repository on a shared server. You assign a nickname to each of the remotes and then can get changes from any of them and send your changes to any or all of them.

By convention, the main repository that a local repository is linked to is called origin. But you can call a remote by any nickname you want. To add a remote, you need the URL for the repository. When you’re on the main page of a repository in GitHub, the URL in the browser is correct, or you can click the <> Code button.

Two places to find the URL of a remote repository when browsing it on github.com.
Two places to find the URL of a remote repository when browsing it on github.com.

Downloading a Remote to Your Computer

The command to create a new repository on your local computer linked to a remote is git clone. If you’ve followed along and created a private repository, wait to type any of these commands; they won’t work yet. If you’ve followed along and created a public repository, use this command:

Extra Steps for Private Repositories

When working with private repositories, you must authenticate when you git clone. However, although Git asks you for your GitHub username, it doesn’t want your GitHub password when it asks for password; it wants your Personal Access Token.

Personal Access Tokens

As you might have seen, you can do much more than look at a repository while on the GitHub website. You can also:

Lfo Sikvontj athoeb ey yra gsonoqo pica. Nua duj mole wu pkvalh mebs hu jefv uk, er'w uxnubz id qta iqc oy xna feyl.
Hsu Keykahnp uvfoip oy dxi ppubona pevi. Yaa tol numo go rbpals lont pu kedw oh, af'm adqeqm or kpo ilb up xze yeqz.

Rre Mezlukpn Cefo zojmaylaoct ove hqu iwwx ami wuo woug he krahw xaw vocrgi suxh anw yegv go qqa catuf weteloreyn.
Lvi Wonwuwhn Zeje sitcibsooph ixo vre ihbl uba fio zoeb de qxomb xak susnwo nemp avh lapf ga gka jeheb laqivovefq.

Conflicts with an Existing Repository

If you already have a Git repository on your computer and want to link it to a GitHub remote, it’s important that you leave the options for README, .gitignore and LICENSE blank so the remote is completely empty.

Sending Your Repository to the Remote

In the local Git repository, you add the remote by typing this command:

Copying Changes to Your Local

Now that you’ve gotten the local and the remote linked and can push your changes, you can learn how to bring changes to your local. The git clone command was to copy an entire repository and initialize a new one on your computer. For an existing, linked repository, get the new changes from the remote using:

See forum comments
Download course materials from Github
Previous: New Repository Demo Next: Push & Pull Demo