how are a remote branch and a remote tracking branch set to correspond to each other?
Git stores remote tracking branches in the remotes/
namespace; see git branch -avv
. The names of remotes and the names of branches make git to remember what local ref corresponds to what remote branch. They are files in .git/refs/remotes/
subdirectory. After git gc/repack
they're packed inside .git/objects/pack/
.
Git updates remote tracking branches when contacting the remote repository during such commands as git fetch/pull/push/remote update
.
how are a remote tracking branch and a local tracking branch set to correspond to each other?
Git remembers that correspondence in the local .git/config
:
[remote "origin"]
url = git@server/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
Now git knows remote tracking branch remotes/origin/master
corresponds to local branch master
.
Are they done during git clone?
Initially, yes.
Are they recorded as some configuration variables in some configuration files?
Yes, in the local .git/config
.
Are they manually modifiable?
Mostly yes, though the amount of work could be high — you need to work in the directory .git/refs/remotes/
and edit .git/config
. And manual operations are impossible for packed references in .git/objects/pack/
. So you better use git
subcommands.