Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Git Basics Working With Remote Repositories Cloning

What is use of git remote?

Hi, Help me understand the use of git remote. I tried playing video twice but was unable to understand. Thanks.

Luiz Felipe Soares
Luiz Felipe Soares
13,840 Points

I think you use git remote to set an alias to your repository. Instead of always typing the full address you just use the alias. And then you are able to fetch a pull data just "calling" the alias instead of the full address... like a bookmark for your remote server.

Correct me if I am wrong.

Cheers

3 Answers

git remote lists your git repository's alias (or aliases). So, for example, if you're trying to push to a git remote repository, then you'll have to use a git command like git push origin master or git push treebook in your terminal. In those examples, the words origin and treebook would be the aliases for their respective projects' repositories. Running git remote in your terminal will tell you the aliases that you can use for your project's repository.

Sorry i didn't get that. Can you give me a example with a url kind of?

How would terminal know, where are my repo hosted e.g treebook or origin?

Matthew Kaplan
Matthew Kaplan
9,226 Points

As you probably know, git is a distributed version control system. Most operations are done locally. To communicate with the outside world, git uses what are called remotes. These are repositories other than the one on your local disk which you can push your changes into (so that other people can see them) or pull from (so that you can get others changes). The command git remote add origin git@github.com:peter/first_app.git creates a new remote called origin located at git@github.com:peter/first_app.git. Once you do this, in your push commands, you can push to origin instead of typing out the whole URL.

Aaron HARPT
Aaron HARPT
19,845 Points

Your remote repository is the version of the repository that is hosted on something like Github.