Working With Remotes

Log - Push - Pull

To see a list of all the connected remote servers, run the command

$ git remote

To see the URLs that Git has stored

$ git remote -v

To add a new remote

$ git remote add _REMOTE_ _URL_

To fetch the data from a remote repository

$ git fetch _REMOTE_

To fetch the data and merge simultaneously

$ git pull _REMOTE_ _BRANCH_

To push to the connected remote server

$ git push _REMOTE_ _BRANCH_

To inspect the remote server

$ git remote show _REMOTE_

To rename a connected server

$ git remote rename _OLDNAME_ _NEWNAME_

To remove a connection with a server

$ git remote remove _REMOTE_

To checkout a remote branch

$ git checkout -b _LOCAL_BRANCH_NAME_ _REMOTE_/_REMOTE_BRANCH_NAME_

To delete a local branch

$ git branch -d _BRANCH_NAME_

To delete a remote branch

$ git push origin :_BRANCH_NAME_

or

$ git push origin --delete _BRANCH_NAME_

To pull and merge unrelated histories, type the command

$ git pull --allow-unrelated-histories _REMOTE_ _BRANCH_