Git Remotes
A remote is a version of your repository hosted elsewhere, typically on a service like GitHub. Remotes let you share your work with others and pull in changes they've made.
The default remote name when you clone a repository is `origin`, but you can add multiple remotes and give them any name you like.
git remote -v
git remote add origin <url>Viewing remotes
Run `git remote -v` to list configured remotes and their URLs, showing both fetch and push addresses.
Adding and removing remotes
Use `git remote add name url` to connect a new remote, and `git remote remove name` to disconnect one.
git remote add origin https://github.com/user/repo.gitConnects the local repository to a GitHub repository named 'origin'.
git remote -vorigin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)Lists the configured remote and shows its URL for both fetching and pushing.
Key points
- A remote is a hosted version of your repository, usually on GitHub.
- The default remote name is origin.
- git remote -v lists configured remotes and their URLs.
- You can have multiple remotes with different names.
