Course contentsShow
← Software Engineering
Lesson 75 of 1,9332. Version Control with GitFree lesson

Adding and Viewing Remotes

Managing remote connections with git remote add, rename, remove, and viewing configured remotes.

Adding and Viewing Remotes

You'll learn: How to connect your local Git repository to remote servers and see which remote connections are configured.

What Are Remote Connections?

You already know that remote repositories exist on servers like GitHub or GitLab (from "What Are Remote Repositories"). But your local Git repository doesn't automatically know where those remotes are located. You need to explicitly tell Git the URLs of remote repositories and give them convenient short names.

Think of remotes like contacts in your phone: instead of typing someone's full phone number every time, you save it under a name like "Mom" or "Boss." Similarly, instead of typing a long URL like https://github.com/company/project.git repeatedly, you give it a nickname like origin.

Adding a Remote

Use git remote add to register a new remote connection:

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

This tells Git: "Remember this URL and call it origin." The name origin is just a convention for the primary remote—you can use any name you want.

Viewing Your Remotes

To see all configured remotes:

git remote

This lists remote names. For more detail (including URLs):

git remote -v

The -v flag shows both fetch and push URLs for each remote.

Managing Remotes

You can rename a remote with git remote rename old-name new-name or remove one entirely with git remote remove name if you no longer need that connection.

Key Takeaway: Use git remote add to connect your local repository to remote servers, and git remote -v to see all configured connections—remotes are simply named shortcuts to repository URLs.