Git Remote
[Git Basic Operations](#)\n\n* * *\n\n**git remote** command is used to manage remote repositories in Git repositories.\n\nThe **git remote** command provides some features for viewing, adding, renaming, and deleting remote repositories.\n\nHere are the common usages of the git remote command:\n\n* `git remote`: List the remote repositories configured in the current repository.\n* `git remote -v`: List the remote repositories configured in the current repository and show their URLs.\n* `git remote add `: Add a new remote repository. Specify a remote repository's name and URL, and add it to the current repository.\n* `git remote rename `: Rename a configured remote repository.\n* `git remote remove `: Remove the specified remote repository from the current repository.\n* `git remote set-url `: Change the URL of the specified remote repository.\n* `git remote show `: Show detailed information about the specified remote repository, including URL and tracking branch.\n\nThe following lists the usage of remote repository, adding remote repository, renaming remote repository, deleting remote repository, modifying remote repository URL, and viewing remote repository information:\n\ngit remote git remote -v git remote add origin https://github.com/user/repo.git git remote rename origin new-origin git remote remove new-origin git remote set-url origin https://github.com/user/new-repo.git git remote show origin\n### Application Examples\n\nIn this chapter, we will use Github as the remote repository for operations. Therefore, before reading this chapter, you need to read the relevant content about Github: [Git Remote Repository (Github)](#).\n\nDisplay all remote repositories:\n\ngit remote -v\ngit remote -v can view the list of remote repositories configured in the current repository and their URLs.\n\nHere we first load the remote repository and then view the information:\n\n$ git clone \n\n $ cd tutorial-git-test\n\n $ git remote-v\n\n origin (fetch)\n\n origin (push)\n\n**origin** is the alias for the remote address.\n\nDisplay information about a certain remote repository:\n\ngit remote show \nFor example:\n\n$ git remote show remote Fetch URL: Push URL: HEAD branch: master Local ref configured for 'git push': master pushes to master (local out of date)\nAdd remote repository:\n\ngit remote add \n* ``: The name of the remote repository to add. Usually, the remote repository is named `origin`, but you can also customize a name.\n* ``: The URL of the remote repository. It can be an HTTPS, SSH, or Git protocol link pointing to a remote Git repository.\n\nThe following command will add a remote repository named origin to the current Git repository, with the URL https://github.com/user/repo.git.\n\ngit remote add origin https://github.com/user/repo.git\nExample usage:\n\n# Submit to Github $ git remote add origin git@github.com:tianqixin/tutorial-git-test.git $ git push -u origin master\nAfter adding a remote repository, you can use other Git commands to interact with the remote repository, such as pushing local code to the remote repository, pulling code from the remote repository, etc.\n\nOther related commands:\n\ngit remote rm name # Delete remote repository git remote rename old_name new_name # Rename repository\nFor more content, please view: [Git Remote Repository (Github)](#).\n\n* * Git Basic Operations](#)
YouTip