Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

Add a remote repository – GitHub

Summary

To add a remote repository to your project, enter the following command in your terminal:

git remote add origin https://github.com/username/repo-name.git

Details

To add a remote repository to an existing local project, use the command above.

Adding a remote repository to your project allows you to push your local changes to the remote repository. This allows you to backup your work online and makes it easier to collaborate with other developers later on.

The core command in the example above is the git remote add. The other parts in the example above (origin and the remote repository URL) are arguments for the command.

In the example above, origin is a name you give to the remote repository that can be used to reference it in future versions.

Here’s a more concrete example. If you’ve created a remote repository on GitHub called my-web-project, you would enter this command in your terminal to add it to your local project:

git remote add origin https://github.com/username/my-web-project.git

The username section of the URL will be your GitHub username.

Exercises

Use the command from the Summary to add the remote repository you created in the previous lesson to your project.

References

Adding a remote from GitHub Help

Back to: GitHub Reference