Skip to content

Commit d390e08

Browse files
calvin-wan-googlegitster
authored andcommitted
Documentation: clarify multiple pushurls vs urls
In a remote with multiple configured URLs, `git remote -v` shows the correct url that fetch uses. However, `git config remote.<remote>.url` returns the last defined url instead. This discrepancy can cause confusion for users with a remote defined as such, since any url defined after the first essentially acts as a pushurl. Add documentation to clarify how fetch interacts with multiple urls and how push interacts with multiple pushurls and urls. Add test affirming interaction between fetch and multiple urls. Signed-off-by: Calvin Wan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 844ede3 commit d390e08

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Documentation/urls-remotes.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ config file would appear like this:
3333
------------
3434

3535
The `<pushurl>` is used for pushes only. It is optional and defaults
36-
to `<URL>`.
36+
to `<URL>`. Pushing to a remote affects all defined pushurls or to all
37+
defined urls if no pushurls are defined. Fetch, however, will only
38+
fetch from the first defined url if muliple urls are defined.
3739

3840
Named file in `$GIT_DIR/remotes`
3941
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

t/t5510-fetch.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,14 @@ test_expect_success 'fetch.writeCommitGraph with submodules' '
806806
)
807807
'
808808

809+
# fetches from first configured url
810+
test_expect_success 'fetch from multiple configured URLs in single remote' '
811+
git init url1 &&
812+
git remote add multipleurls url1 &&
813+
git remote set-url --add multipleurls url2 &&
814+
git fetch multipleurls
815+
'
816+
809817
# configured prune tests
810818

811819
set_config_tristate () {

0 commit comments

Comments
 (0)