git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Cannot override `remote.origin.url` with `-c` option
@ 2024-06-09  6:51 Mathew George
  2024-06-11  7:51 ` Jeff King
  0 siblings, 1 reply; 29+ messages in thread
From: Mathew George @ 2024-06-09  6:51 UTC (permalink / raw)
  To: git

> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.

> What did you do before the bug happened? (Steps to reproduce your issue)

```
# Create a test repo to pull into
git init test
cd $_
git remote add origin wrong-url
# Create a test repo to pull from
git init ../test2
cd $_
touch a
git add .
git commit -m 'commit to pull'
# Attempt to pull, setting remote.origin.url
# The following git commands will fail:
cd ../test
git -c remote.origin.url=../test2 pull
git -c remote.origin.url=../test2 fetch
# However, this succeeds:
git pull ../test2
```


> What did you expect to happen? (Expected behavior)

The '-c' option should allow me to override the remote URL,
which, as a result of running `git remote add`, is configured as
follows in test/.git/config:

```
[remote "origin"]
	url = wrong-url
```

From git(1): 
```
-c <name>=<value>
    Pass a configuration parameter to the command. The
    value given will override values from configuration
    files.
```


> What happened instead? (Actual behavior)

The following errors are produced for both 'fetch' and 'pull'
operations:

```
fatal: 'wrong-url' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```

Regardless of the -c option, the commands above use the url
'wrong-url' from .git/config.


> What's different between what you expected and what actually
> happened?

The -c option is not respected.


> Anything else you want to add:

It may be that this is not supported, but if that's the case, I
missed any documentation saying so.


> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.


[System Info]
git version:
git version 2.45.2
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /usr/bin/sh
compiler info: clang: 17.0.2 (https://android.googlesource.com/toolchain/llvm-project d9f89f4d16663d5012e5c09495f3b30ece3d2362)
libc info: no libc information available
$SHELL (typically, interactive shell): /usr/bin/bash


[Enabled Hooks]
not run from a git repository - no hooks to show

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2024-06-26 20:40 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-09  6:51 Cannot override `remote.origin.url` with `-c` option Mathew George
2024-06-11  7:51 ` Jeff King
2024-06-11 15:28   ` Junio C Hamano
2024-06-13 10:24     ` Jeff King
2024-06-14 10:24       ` [PATCH 0/11] allow overriding remote.*.url Jeff King
2024-06-14 10:25         ` [PATCH 01/11] archive: fix check for missing url Jeff King
2024-06-14 10:26         ` [PATCH 02/11] remote: refactor alias_url() memory ownership Jeff King
2024-06-14 17:05           ` Junio C Hamano
2024-06-14 10:27         ` [PATCH 03/11] remote: transfer ownership of memory in add_url(), etc Jeff King
2024-06-14 17:04           ` Junio C Hamano
2024-06-16  4:59             ` Jeff King
2024-06-17 17:42               ` Junio C Hamano
2024-06-25 17:30           ` Elijah Newren
2024-06-14 10:28         ` [PATCH 04/11] remote: use strvecs to store remote url/pushurl Jeff King
2024-06-25 17:32           ` Elijah Newren
2024-06-14 10:29         ` [PATCH 05/11] remote: simplify url/pushurl selection Jeff King
2024-06-25 17:33           ` Elijah Newren
2024-06-14 10:30         ` [PATCH 06/11] config: document remote.*.url/pushurl interaction Jeff King
2024-06-25 17:34           ` Elijah Newren
2024-06-14 10:31         ` [PATCH 07/11] remote: allow resetting url list Jeff King
2024-06-25 17:35           ` Elijah Newren
2024-06-14 10:31         ` [PATCH 08/11] t5801: make remote-testgit GIT_DIR setup more robust Jeff King
2024-06-25 17:36           ` Elijah Newren
2024-06-14 10:34         ` [PATCH 09/11] t5801: test remote.*.vcs config Jeff King
2024-06-14 10:37         ` [PATCH 10/11] remote: always require at least one url in a remote Jeff King
2024-06-14 10:42         ` [PATCH 11/11] remote: drop checks for zero-url case Jeff King
2024-06-25 17:37           ` Elijah Newren
2024-06-25 17:44         ` [PATCH 0/11] allow overriding remote.*.url Elijah Newren
2024-06-26 20:40           ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).