Skip to content

Commit

Permalink
Documentation: clarify multiple pushurls vs urls
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
calvin-wan-google authored and gitster committed Feb 7, 2023
1 parent 844ede3 commit d390e08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Documentation/urls-remotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ config file would appear like this:
------------

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

Named file in `$GIT_DIR/remotes`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
8 changes: 8 additions & 0 deletions t/t5510-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,14 @@ test_expect_success 'fetch.writeCommitGraph with submodules' '
)
'

# fetches from first configured url
test_expect_success 'fetch from multiple configured URLs in single remote' '
git init url1 &&
git remote add multipleurls url1 &&
git remote set-url --add multipleurls url2 &&
git fetch multipleurls
'

# configured prune tests

set_config_tristate () {
Expand Down

0 comments on commit d390e08

Please sign in to comment.