Ways to configure remote in git

Viewed 81

After reading this , I understood that there are 3 ways to mention url of a remote along with push and pull ref spec in case they are skipped for git push/pull.

a remote in the Git configuration file: $GIT_DIR/config,

a file in the $GIT_DIR/remotes directory, or

a file in the $GIT_DIR/branches directory.

What is the priority order among them in case conflicting values occur ?

1 Answers

If you consider t/t5505-remote.sh#migrate a remote from named file in $GIT_DIR/branches (2), you will see that a file in .git/branches/ is actually transformed into a .gitconfig remote refspec.

See git remote rename:

rename the remote named <old> to <new>.
All remote-tracking branches and configuration settings for the remote are updated.

In case <old> and <new> are the same, and <old> is a file under $GIT_DIR/remotes or $GIT_DIR/branches, the remote is converted to the configuration file format.

So .gitconfig is clearly first.
From the tests, $GIT_DIR/remotes is second, $GIT_DIR/branches is third.

Related