ardabro
ardabro

Reputation: 2061

remote.origin.fetch - how is set by default, what it depends on and may it change without explicit git config?

Last time I struggled with problem that my remote.origin.fetch changed to empty value so that I couldn't operate on remote branches. When I resorted to clone remote repository again (as bare) it turned out that my remote.origin.fetch is empty by default(!). I have other remote bound with the same local and observed no issues with the second. (actually both of them have other aliases than "origin" but it probably doesn't matter here). git fsck didn't show any issues.

I see I don't understand something.

What determines remote.origin.fetch value when I'm cloning remote repo? May it depend (be forced by) on remote server setting (gerrit,bitbucket,gitlab,github)?

How remote.origin.fetch value may be changed in my local repo except with explicit git config command? May it happen during fetch or silently "under" other specific command?

Upvotes: 2

Views: 375

Answers (1)

Romain Valeri
Romain Valeri

Reputation: 21998

It is set when your remote is created, which happens automatically when you do your git clone. It's created along with remote.origin.push as part of the default remote creation process.

From the doc :

Showing Your Remotes

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. If you’ve cloned your repository, you should at least see origin — that is the default name Git gives to the server you cloned from

(emphasis mine)

So I guess the key point is the --bare cloning. Bare repositories don't have remotes set like non-bare ones.

The relevant passage in the --bare doc is

Also the branch heads at the remote are copied directly to corresponding local branch heads, without mapping them to refs/remotes/origin/. When this option is used, neither remote-tracking branches nor the related configuration variables are created.

Upvotes: 1

Related Questions