Remote Configuration
Keeping track of all of the information about a remote repository reference can become tedious and difficult: you have to remember the full URL for the repository; you must type and retype remote references and refspecs on the command line each time you want to fetch updates; you have to reconstruct the branch mappings; and so on. Repeating the information is also likely to be quite error-prone.
You might also wonder how Git remembers the URL for the remote
from the initial clone for use in subsequent fetch or push operations
using origin.
Git provides three mechanisms for setting up and maintaining information about remotes: the git remote command, the git config command, and editing the .git/config file directly. All three mechanisms ultimately result in configuration information being recorded in the .git/config file.
git remote
The git remote command is a more specialized interface, specific to remotes, that manipulates the configuration file data. It has several subcommands with fairly intuitive names. There is no “help” option, but you can circumvent that to display a message with subcommand names via the “unknown subcommand trick”:
$ git remote xyzzy
error: Unknown subcommand: xyzzy
usage: git remote
or: git remote add <name> <url>
or: git remote rm <name>
or: git remote show <name>
or: git remote prune <name>
or: git remote update [group]
-v, --verbose be verboseYou saw the git remote add and update commands in Make Your Own origin Remote, and show in Adding ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access