In Git, the term remote is concerned with the remote repository. It is a shared repository that all team members use to exchange their changes. A remote repository is stored on a code hosting service like an internal server, Gitopia, GitHub, Subversion, and more.
The developers can perform many operations with the remote server. These operations can be a clone, fetch, push, pull, and more.
Check your Remote
To check the configuration of the remote server, run the
git remote command. The
git remote command allows accessing the connection between remote and local. If you want to see the original existence of your cloned repository, use the
git remote command. It can be used as:
The command is providing the remote name as the
origin is the human-friendly name for the URL that the remote repository is stored at. It's like a key value pair, and
origin is the default.
Git Remote Common Usage
git remote -v: List the current remotes associated with the local repository.
git remote -v
origin gitopia://gitopia147dgrtq5ywww473uz680fx2ucex9fv3qnw94zm/hello-world (fetch)
origin gitopia://gitopia147dgrtq5ywww473uz680fx2ucex9fv3qnw94zm/hello-world (push)
git remote add [name] [remote-URL]: Add a remote.
git remote add origin gitopia://gitopia147dgrtq5ywww473uz680fx2ucex9fv3qnw94zm/hello-world
git remote remove <name>(or)
git remote rm <name>: Remove a remote.
git remote remove origin
$ git remote rename <old name><new name>: Rename the remote server.
git remote rename origin dev
$ git remote show <remote>: To see additional information about a particular remote.
git remote show origin
* remote origin
Fetch URL: gitopia://gitopia147dgrtq5ywww473uz680fx2ucex9fv3qnw94zm/hello-world
Push URL: gitopia://gitopia147dgrtq5ywww473uz680fx2ucex9fv3qnw94zm/hello-world
HEAD branch: master
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
You can learn more about the
git remotecommand and its options in git-scm's documentation.
Communicating with the Remote
There are four commands within Git that prompt communication with the remote. Unless you are using one of these four commands, all of your work is only happening locally.
git push: Uploads all local branch commits to the remote. The git push command is used to share a project or send updates to the remote server. Visit Git Push.
git clone: To clone the remote repository from your remote projects. Visit Git Clone.
git pull: Updates your current local working branch with all new commits from the corresponding remote branch on Git hosting server. Visit Git Pull.
git fetch: To fetch the data from remote projects. Visit Git Fetch.