Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $ credit.
This credit will be applied to any valid services used during your first  days.

A remote Git repository can be on a server, a Git cloud service (such as GitHub, GitLab, or Bitbucket), or on another developer’s machine. That enables many possible workflows for teams. One common workflow involves using a server repository as the “authorized” repository. Only reviewed, well-tested code is committed to it, often through a pull request issued from a developer’s repository.

What is a Git Remote?

A Git remote simply references a remote repository. Typically, there is at least one Git remote in a repository, named origin. Sometimes there are additional Git remotes in a repository, for example upstream. The term upstream generally refers to a repository from which another repository is derived, usually by cloning.

Create a remote in a local repository using the git remote add command, for example:

git remote add origin https://github.com/user/repo.git

In this example, the first parameter, origin, is the name of the remote. The second parameter, https://github.com/user/repo.git, is the URL of the remote repository.

List the remotes in a repository using the git remote -v command, where the -v flag is short for --verbose. This instructs the git remote command to include the remote URL in the list. For example, use the git remote -v command in a folder containing the TensorFlow repository:

cd repos/tensorflow/
git remote -v

This produces output such as:

origin	https://github.com/tensorflow/tensorflow.git (fetch)
origin	https://github.com/tensorflow/tensorflow.git (push)

How to Remove a Git Remote

There are three steps to remove a Git remote, with an optional verification step to confirm the removal.

  1. First, open a terminal and change into the directory that holds your repository:

    cd repos/tensorflow/
  2. Second, list the remotes:

    git remote -v
    origin	https://github.com/tensorflow/tensorflow.git (fetch)
    origin	https://github.com/tensorflow/tensorflow.git (push)
  3. Third, remove the remote/s:

    git remote rm origin

    In current versions of Git there are two forms of the command to remove a remote: rm and remove. The rm form goes back to the early versions of Git, while the remove form was later added as an alias to help Windows users.

    Note
    The git remote rm command simply removes the entries for the remote repository from the .git/config file. It does not affect the actual remote repository. There is no need to worry about deleting the remote repository on the server as that cannot be done from a local Git command.

    There’s only one possible error message after issuing a git remote rm command:

    fatal: No such remote: '<remote-name>'.
  4. A fourth, optional step is to confirm that step three worked by repeating step two:

    git remote -v

    This time, the removed remotes should not show up in the list. If all remotes were deleted, there is no output.

Note

Alternatively, removing a remote and adding a new remote can be accomplished in one step using the git remote set-url command, for example:

git remote set-url origin git@github.com:<github-username>/<repository-name>.git

To test this without modifying an established repository, create a new test repository on a Git hosting service (e.g. GitHub). Clone the new test repository to your local machine, then repeat the steps above in the cloned repository. A repository containing nothing but a small README.md suffices.

Conclusion

To summarize, create a remote in a local repository using the git remote add command. List remotes using the git remote -v command, and remove them using the git remote rm command. This easy three- or four-step sequence for removing a remote is immensely helpful for anyone working with Git.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This page was originally published on


Your Feedback Is Important

Let us know if this guide was helpful to you.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.
The Disqus commenting system for Linode Docs requires the acceptance of Functional Cookies, which allow us to analyze site usage so we can measure and improve performance. To view and create comments for this article, please update your Cookie Preferences on this website and refresh this web page. Please note: You must have JavaScript enabled in your browser.