Git remote basics

Below are some basic git commands I have found useful. In particular when it comes down working with multiple repositories.

In order to see the remote repositories you currently have set up you will need to enter the following:
$  git remote -v
This will show you the "Fetch" and "Push" URLS for each remote.
If you want to add a completely new remote you must enter:
$  git remote add [remoteName] [url]
Note: This has to be a unique name. As "Origin" is always the default you will need to enter a different name.
If you want to remove a remote which you have set up you must enter:
$  git remote remove [remoteName]
In order to edit a remotes URL:
$  git remote set-url [remoteName] [url]
You can see where the remotes Fetch and Push urls are pointing you by entering the following:
$  git remote show [remoteName]
To pull from a particular repository:
$  git pull [remoteName] [branch]
An example of this would be git pull origin master
To push from a particular repository:
$  git push [remoteName] [branch]
An example of this would be git push origin master

Leave a Reply