git remote Command
The git remote command is used for operations on remote repositories.
In this section, we will use Github as the remote repository, so before reading this section, you need to read the relevant content about Github: Git Remote Repository (Github).
Display all remote repositories:
git remote -v
First, let's load a remote repository and then view its information:
$ git clone https://github.com/tianqixin/tutorialpro-git-test
$ cd tutorialpro-git-test
$ git remote -v
origin https://github.com/tianqixin/tutorialpro-git-test (fetch)
origin https://github.com/tianqixin/tutorialpro-git-test (push)
origin is the alias for the remote URL.
Display information about a specific remote repository:
git remote show [remote]
For example:
$ git remote show https://github.com/tianqixin/tutorialpro-git-test
* remote https://github.com/tianqixin/tutorialpro-git-test
Fetch URL: https://github.com/tianqixin/tutorialpro-git-test
Push URL: https://github.com/tianqixin/tutorialpro-git-test
HEAD branch: master
Local ref configured for 'git push':
master pushes to master (local out of date)
Add a remote repository:
git remote add [shortname] [url]
shortname refers to the local repository, for example:
# Push to Github
$ git remote add origin [email protected]:tianqixin/tutorialpro-git-test.git
$ git push -u origin master
Other related commands:
git remote rm name # Delete a remote repository
git remote rename old_name new_name # Rename a repository
For more content, see: Git Remote Repository (Github).