Remotes are versions of your project that are hosted on the internet or network somewhere. These commands allow you to collaborate with others by syncing your local repository with the remote servers.
Connects your local repository to a remote server. Usually the first remote is called origin.
git remote add origin $remote_urlThe very first time you push your code, you need to set the upstream tracking branch using -u.
git push -u origin mainPulling fetches the data from the remote server and automatically tries to merge it into your current working code.
git pull $remote $remote_branchWhen you have local commits that you want to share, you push them upstream. If you've rewritten history (like via a rebase), you may need to force push. --force-with-lease is a safer alternative to --force that ensures you don't overwrite someone else's work blindly.
git push $force $remote $branchFetching downloads the objects and refs from the remote repository, but does not merge them into your local branches. It is a completely safe operation to see what others have been working on.
git fetch $remotegit remote rename $remote $new_remoteUpdate the URL for an existing remote (e.g. switching from HTTPS to SSH).
git remote set-url $remote $remote_urlRemoves local references to remote branches that have been deleted on the server.
git remote prune $remote