Working with Remotes in Git
To be able to collaborate on any Git project, you need to know how to manage your remote repositories.
To see which remote servers you have configured, you can run the
git remote command. It lists the shortnames of each remote handle you’ve specified.
To add a new remote, use the
git remote add command in the directory your repository is stored at.
The command takes two arguments: a remote name (e.g.
origin) and a remote URL.
To change a remote's shortname, use the
git remote rename command in the directory your repository is stored at.
The command takes two arguments: the current shortname and the new shortname.
To remove the reference to the remote repository, use the
git remote removecommand in the directory your repository is stored at.
The command takes one argument: the current shortname of the reference you want to delete.
git clone command clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository, and creates and checks out an initial branch that is forked from the cloned repository’s currently active branch.
If you clone a repository, the command automatically adds that remote repository under the name
Git fetch and git pull
git fetch only downloads the data to your local repo, it doesn’t automatically merge it with any of your work or modify what you’re currently working on. You have to merge it manually into your work when you’re ready.
git pull is a shorthand for the
git fetch (downloads the data to your local repo) followed by
git merge (join two or more development histories together).
git push command is used to upload local repository content to a remote repository.