{"thread":{"id":"57192","subject":"Git bug report git remote get-url","startedAt":"2022-01-05T17:30:11Z","lastAt":"2022-01-06T00:22:35Z","messageCount":2,"participants":["Nanekrangsan, Sucheela (NYC-GIS)","Taylor Blau"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"445549","messageId":"00FDB880-5FF6-4C67-9144-5599B2872830@interpublic.com","threadId":"57192","inReplyTo":null,"subject":"Git bug report git remote get-url","fromName":"Nanekrangsan, Sucheela (NYC-GIS)","fromEmail":"sucheela.nanekrangsan@interpublic.com","sentAt":"2022-01-05T17:22:06Z","receivedAt":"2022-01-05T17:30:11Z","isPatch":false,"sender":{"key":"sucheela.nanekrangsan@interpublic.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n1. I put [remote] entries in /etc/gitconfig\n2. `git config --get remote.xxx.url` returns the correct URL. I can `git pull` from this remote.\n3. `git remote get-url xxx` returns \"error: No such remote 'xxx'\"\n4. After `git remote add xxx`, I can get the URL from `git remote get-url`.\nWhat did you expect to happen? (Expected behavior)\nI expected `git-remote get-url` to give me the URL I added in /etc/gitconfig. \n\nWhat happened instead? (Actual behavior)\n`git remote get-url` did not recognize the report I added in /etc/gitconfig.\n\nWhat's different between what you expected and what actually happened?\nI expected the URL from /etc/gitconfig from `git remote get-url` but got error.\n\nAnything else you want to add:\nThese give me the correct results\n`git config --get remote.xxx.url`\n`git ls-remote --get-url xxx`\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.34.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 3.10.0-1160.49.1.el7.x86_64 #1 SMP Tue Nov 30 15:51:32 UTC 2021 x86_64\ncompiler info: gnuc: 4.8\nlibc info: glibc: 2.17\n$SHELL (typically, interactive shell): /bin/bash\n\n\n\nThis message contains information which may be confidential and privileged. Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message.  If you have received the message in error, please advise the sender by reply e-mail, and delete the message.  Thank you very much.\n"},{"id":"445600","messageId":"YdY2P+xX/a6aHB2b@nand.local","threadId":"57192","inReplyTo":"00FDB880-5FF6-4C67-9144-5599B2872830@interpublic.com","subject":"Re: Git bug report git remote get-url","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-01-06T00:22:23Z","receivedAt":"2022-01-06T00:22:35Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, Jan 05, 2022 at 05:22:06PM +0000, Nanekrangsan, Sucheela (NYC-GIS) wrote:\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n>\n> What did you do before the bug happened? (Steps to reproduce your issue)\n> 1. I put [remote] entries in /etc/gitconfig\n\nThis is almost certainly the culprit.\n\n`git remote get-url` doesn't output anything (except the error message\nincluded in your report) when `remote->configured_in_repo` is zero.\nIndeed, looking at remote.c:handle_config() where we actually add a new\nremote:\n\n    remote = make_remote(remote_state, name, namelen);\n    remote->origin = REMOTE_CONFIG;\n    if (current_config_scope() == CONFIG_SCOPE_LOCAL ||\n        current_config_scope() == CONFIG_SCOPE_WORKTREE)\n            remote->configured_in_repo = 1;\n\nwe only set configured_in_repo when we're looking at local or\nworktree configuration. Since $(prefix)/etc/gitconfig isn't either of\nthose, we'll avoid setting configured_in_repo, hence we'll end up inside\nof this if-statement in builtin/remote.c:get_url():\n\n    remote = remote_get(remotename);\n    if (!remote_is_configured(remote, 1)) {\n            error(_(\"No such remote '%s'\"), remotename);\n            exit(2);\n    }\n\n...producing the error message in your report.\n\n> 4. After `git remote add xxx`, I can get the URL from `git remote get-url`.\n\nThis makes sense, since `git remote add` will configure the remote `xxx`\nin your repository-local configuration, not the system-wide one.\n\nThanks,\nTaylor\n"}]}