Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Syncing ability of the git allows the developers to access and work on any project anytime anywhere. The collaboration among developers via git takes place when git provides each individual developer a separate copy of the repository.
Git relies on the basis of distributed development of software where more than one developer may have access to the source code of a specific application and can modify changes to it which may be seen by other developers. This is done by connecting the online repository with the developer’s local repository by remote access. Git provides a command ‘
remote‘ to do the above-mentioned task.
remote‘ command helps you to manage the set of repository whose branches you track. This command is used to perform the sync operations required to keep the local repository updated as per the central repository and also to update the changes made by the developer in the local repository on the central repository. These changes are pushed or fetched to/from the central repository with the use of
Working with remote repositories is made easier with the use of some sub-commands under
git remote command.
There are two ways of finding remote repositories linked with the local repository:
- git remote: This git command lists all the remote connections of your local repository that you have with the other repositories.
- git remote -v(or ‐‐verbose): This git command works similar to the previous command the only difference is that it lists the remote connections of your local repository that you have with other repositories along with the URL of the connections.
git remote commands
To perform various operations on the remote repositories, Git provides some remote commands that can be used to manipulate remote repositories. These commands are like adding a remote repository, renaming a remote repository, etc. Following are some commands along with their description to get a good hand knowledge about remotes:
git remote add
remote add‘ command is used to create a new connection named [name] for the repository at the given[URL]. Further, after adding a remote repository,
show command can be used to display all the connected remotes.
Note: The command git fetch [name] can then be used to create and update remote-tracking branches [name]/[branch].
git remote rename
Git allows renaming a remote repository as per the user’s need in order to provide a smooth user experience working with git repositories. This can be done by using ‘
remote rename‘ command. This git command renames the remote named [old] to a [new] remote name.
git remote rm
remote rm‘ command is used to remove an existing remote repository. Name of the existing remote repository is passed to the command as argument and the referred remote repository is unlinked from the local repository.
git remote get-url
Git allows performing operations with the URL of the remote repository. This git command is used to retrieve the URL of a remote repository with which it is linked to the local repository.
git remote set-url
Just like Git allows fetching the URL of a remote repository, it also allows changing the existing URL of the repository. This git ‘
remote set-url‘ command performs the job of setting or updating the URL of a remote repository. This command sets the first URL if no [oldurl] is given to [newurl]. If [oldurl] doesn’t match any URL, an error occurs and nothing is changed.
git remote show
Git allows fetching the names of the existing remote repositories that are linked to the local repositories. This git command gives some information about the connection with the remote [name].
- Bare Repositories in Git
- Working with Git Repositories
- Pushing changes to a Git Repository
- What is a GIT Repository?
- Git Features
- Merge Strategies in Git
- Getting changes from a Git Repository
- Git | Working with Stash
- Using Git on CommandLine
- Working on BitBucket using Git
- Working on Git for GUI
- Using Patches in Git
- Rebasing of branches in Git
- Recovering Lost Commits in Git
- Working on Git Bash
- Jenkins and GIT Integration using SSH Key
- Difference Between Git and GitHub
- Using Tags in Git
- What is Collaboration in Git?
- Patch Operation in Git
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.