{"thread":{"id":"62043","subject":"`git remote set-branches (without --add) <name> <branch>…​` does not add refspecs to `remote.<remote>.fetch` when `remote.<remote>.fetch` does not exist","startedAt":"2024-09-03T10:38:06Z","lastAt":"2024-09-10T11:02:10Z","messageCount":5,"participants":["Han Jiang","Phillip Wood"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"502027","messageId":"CANrWfmR1y64OP+506JUO3Beic9kn5_TrhMQ1ZucVcDEn03noLg@mail.gmail.com","threadId":"62043","inReplyTo":null,"subject":"`git remote set-branches (without --add) <name> <branch>…​` does not add refspecs to `remote.<remote>.fetch` when `remote.<remote>.fetch` does not exist","fromName":"Han Jiang","fromEmail":"jhcarl0814@gmail.com","sentAt":"2024-09-03T10:37:54Z","receivedAt":"2024-09-03T10:38:06Z","isPatch":false,"sender":{"key":"jhcarl0814@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5171262?v=4"},"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)\n\ncd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir \"$_\"; cd \"$_\";\nmkdir --parents -- './server' './client';\ngit -C './client' init './repo'\ngit -C './client/repo' remote --verbose\ngit -C './client/repo' config list --local --show-scope --show-origin\ngit -C './client/repo' remote add server 'file://'\"$(realpath\n'./server/repo.git')\"\ngit -C './client/repo' remote --verbose\ngit -C './client/repo' config list --local --show-scope --show-origin\ngit -C './client/repo' remote set-branches server branch1 branch2\ngit -C './client/repo' config list --local --show-scope --show-origin\ngit -C './client/repo' remote set-branches --add server branch3 branch4\ngit -C './client/repo' config list --local --show-scope --show-origin\ngit -C './client/repo' remote set-branches --add server branch3 branch4\ngit -C './client/repo' config list --local --show-scope --show-origin\ngit -C './client/repo' remote set-branches server\ngit -C './client/repo' config list --local --show-scope --show-origin\ngit -C './client/repo' remote set-branches server branch1 branch2\ngit -C './client/repo' config list --local --show-scope --show-origin\ngit -C './client/repo' remote set-branches --add server branch3 branch4\ngit -C './client/repo' config list --local --show-scope --show-origin\ngit -C './client/repo' remote set-branches --add server branch3 branch4\ngit -C './client/repo' config list --local --show-scope --show-origin\n\nWhat did you expect to happen? (Expected behavior)\n\n(local config has branch1 and branch2:)\nremote.server.fetch=+refs/heads/branch1:refs/remotes/server/branch1\nremote.server.fetch=+refs/heads/branch2:refs/remotes/server/branch2\nremote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\nremote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\nremote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\nremote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n\nWhat happened instead? (Actual behavior)\n\n(local config does not have branch1 and branch2:)\nremote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\nremote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\nremote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\nremote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n\nWhat's different between what you expected and what actually happened?\n\nAnything else you want to add:\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.46.0.windows.1\ncpu: x86_64\nbuilt from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d\nsizeof-long: 4\nsizeof-size_t: 8\nshell-path: D:/git-sdk-64-build-installers/usr/bin/sh\nfeature: fsmonitor--daemon\nlibcurl: 8.9.0\nOpenSSL: OpenSSL 3.2.2 4 Jun 2024\nzlib: 1.3.1\nuname: Windows 10.0 22631\ncompiler info: gnuc: 14.1\nlibc info: no libc information available\n$SHELL (typically, interactive shell): C:\\Program Files\\Git\\usr\\bin\\bash.exe\n\n\n[Enabled Hooks]\nnot run from a git repository - no hooks to show\n"},{"id":"502203","messageId":"612756e2-fc84-4d49-9f74-ff1998f66f7c@gmail.com","threadId":"62043","inReplyTo":"CANrWfmR1y64OP+506JUO3Beic9kn5_TrhMQ1ZucVcDEn03noLg@mail.gmail.com","subject":"Re: `git remote set-branches (without --add) <name> <branch>… ` does not add refspecs to `remote.<remote>.fetch` when `remote.<remote>.fetch` does not exist","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2024-09-05T09:07:17Z","receivedAt":"2024-09-05T09:07:21Z","isPatch":false,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 03/09/2024 11:37, Han Jiang 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\nIt is always helpful to show how to reproduce a bug but please try and \naim for a minimal reproduction recipe. It is much easier to follow if \nyou show which output lines come from which command. In this case one \ncan reproduce the issue with\n\n$ git remote add test git@example.com\n$ git config --get-all remote.test.fetch\n+refs/heads/*:refs/remotes/test/*\n$ git config --unset-all remote.test.fetch\n$ git config --get-all remote.test.fetch\n$ git remote set-branches test main topic\n$ git config --get-all remote.test.fetch\n\nI haven't looked into what causes this. I wonder how likely users are to \nbe affected - how did you get into a state where there was no fetch \nrefspec set for your remote?\n\nBest Wishes\n\nPhillip\n\n> cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir \"$_\"; cd \"$_\";\n> mkdir --parents -- './server' './client';\n> git -C './client' init './repo'\n> git -C './client/repo' remote --verbose\n> git -C './client/repo' config list --local --show-scope --show-origin\n> git -C './client/repo' remote add server 'file://'\"$(realpath\n> './server/repo.git')\"\n> git -C './client/repo' remote --verbose\n> git -C './client/repo' config list --local --show-scope --show-origin\n> git -C './client/repo' remote set-branches server branch1 branch2\n> git -C './client/repo' config list --local --show-scope --show-origin\n> git -C './client/repo' remote set-branches --add server branch3 branch4\n> git -C './client/repo' config list --local --show-scope --show-origin\n> git -C './client/repo' remote set-branches --add server branch3 branch4\n> git -C './client/repo' config list --local --show-scope --show-origin\n> git -C './client/repo' remote set-branches server\n> git -C './client/repo' config list --local --show-scope --show-origin\n> git -C './client/repo' remote set-branches server branch1 branch2\n> git -C './client/repo' config list --local --show-scope --show-origin\n> git -C './client/repo' remote set-branches --add server branch3 branch4\n> git -C './client/repo' config list --local --show-scope --show-origin\n> git -C './client/repo' remote set-branches --add server branch3 branch4\n> git -C './client/repo' config list --local --show-scope --show-origin\n> \n> What did you expect to happen? (Expected behavior)\n> \n> (local config has branch1 and branch2:)\n> remote.server.fetch=+refs/heads/branch1:refs/remotes/server/branch1\n> remote.server.fetch=+refs/heads/branch2:refs/remotes/server/branch2\n> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> \n> What happened instead? (Actual behavior)\n> \n> (local config does not have branch1 and branch2:)\n> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> \n> What's different between what you expected and what actually happened?\n> \n> Anything else you want to add:\n> \n> Please review the rest of the bug report below.\n> You can delete any lines you don't wish to share.\n> \n> \n> [System Info]\n> git version:\n> git version 2.46.0.windows.1\n> cpu: x86_64\n> built from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d\n> sizeof-long: 4\n> sizeof-size_t: 8\n> shell-path: D:/git-sdk-64-build-installers/usr/bin/sh\n> feature: fsmonitor--daemon\n> libcurl: 8.9.0\n> OpenSSL: OpenSSL 3.2.2 4 Jun 2024\n> zlib: 1.3.1\n> uname: Windows 10.0 22631\n> compiler info: gnuc: 14.1\n> libc info: no libc information available\n> $SHELL (typically, interactive shell): C:\\Program Files\\Git\\usr\\bin\\bash.exe\n> \n> \n> [Enabled Hooks]\n> not run from a git repository - no hooks to show\n> \n"},{"id":"502294","messageId":"CANrWfmS9PCKyK3X0rFnWfecrn-ETmcdtoPtA6j9QS7nTwfivKg@mail.gmail.com","threadId":"62043","inReplyTo":"612756e2-fc84-4d49-9f74-ff1998f66f7c@gmail.com","subject":"Re: `git remote set-branches (without --add) <name> <branch>… ` does not add refspecs to `remote.<remote>.fetch` when `remote.<remote>.fetch` does not exist","fromName":"Han Jiang","fromEmail":"jhcarl0814@gmail.com","sentAt":"2024-09-05T22:24:46Z","receivedAt":"2024-09-05T22:24:59Z","isPatch":false,"sender":{"key":"jhcarl0814@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5171262?v=4"},"body":"A way to get into the state is `git remote set-branches <remote>`\n(followed by zero <branch>es), which removes `remote.server.fetch`\nconfiguration variable. After that, `git remote set-branches <remote>\n<branch>…` does not work. (But `git remote set-branches --add` can be\nused to get out of the corrupted state.)\n\nShortened version of the example:\ngit remote add server git@example.com\ngit config list --local\ngit remote set-branches server\ngit config list --local\ngit remote set-branches server branch1 branch2\ngit config list --local\n\nOn Thu, Sep 5, 2024 at 9:07 PM Phillip Wood <phillip.wood123@gmail.com> wrote:\n>\n> On 03/09/2024 11:37, Han Jiang 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>\n> It is always helpful to show how to reproduce a bug but please try and\n> aim for a minimal reproduction recipe. It is much easier to follow if\n> you show which output lines come from which command. In this case one\n> can reproduce the issue with\n>\n> $ git remote add test git@example.com\n> $ git config --get-all remote.test.fetch\n> +refs/heads/*:refs/remotes/test/*\n> $ git config --unset-all remote.test.fetch\n> $ git config --get-all remote.test.fetch\n> $ git remote set-branches test main topic\n> $ git config --get-all remote.test.fetch\n>\n> I haven't looked into what causes this. I wonder how likely users are to\n> be affected - how did you get into a state where there was no fetch\n> refspec set for your remote?\n>\n> Best Wishes\n>\n> Phillip\n>\n> > cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir \"$_\"; cd \"$_\";\n> > mkdir --parents -- './server' './client';\n> > git -C './client' init './repo'\n> > git -C './client/repo' remote --verbose\n> > git -C './client/repo' config list --local --show-scope --show-origin\n> > git -C './client/repo' remote add server 'file://'\"$(realpath\n> > './server/repo.git')\"\n> > git -C './client/repo' remote --verbose\n> > git -C './client/repo' config list --local --show-scope --show-origin\n> > git -C './client/repo' remote set-branches server branch1 branch2\n> > git -C './client/repo' config list --local --show-scope --show-origin\n> > git -C './client/repo' remote set-branches --add server branch3 branch4\n> > git -C './client/repo' config list --local --show-scope --show-origin\n> > git -C './client/repo' remote set-branches --add server branch3 branch4\n> > git -C './client/repo' config list --local --show-scope --show-origin\n> > git -C './client/repo' remote set-branches server\n> > git -C './client/repo' config list --local --show-scope --show-origin\n> > git -C './client/repo' remote set-branches server branch1 branch2\n> > git -C './client/repo' config list --local --show-scope --show-origin\n> > git -C './client/repo' remote set-branches --add server branch3 branch4\n> > git -C './client/repo' config list --local --show-scope --show-origin\n> > git -C './client/repo' remote set-branches --add server branch3 branch4\n> > git -C './client/repo' config list --local --show-scope --show-origin\n> >\n> > What did you expect to happen? (Expected behavior)\n> >\n> > (local config has branch1 and branch2:)\n> > remote.server.fetch=+refs/heads/branch1:refs/remotes/server/branch1\n> > remote.server.fetch=+refs/heads/branch2:refs/remotes/server/branch2\n> > remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> > remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> > remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> > remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> >\n> > What happened instead? (Actual behavior)\n> >\n> > (local config does not have branch1 and branch2:)\n> > remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> > remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> > remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> > remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> >\n> > What's different between what you expected and what actually happened?\n> >\n> > Anything else you want to add:\n> >\n> > Please review the rest of the bug report below.\n> > You can delete any lines you don't wish to share.\n> >\n> >\n> > [System Info]\n> > git version:\n> > git version 2.46.0.windows.1\n> > cpu: x86_64\n> > built from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d\n> > sizeof-long: 4\n> > sizeof-size_t: 8\n> > shell-path: D:/git-sdk-64-build-installers/usr/bin/sh\n> > feature: fsmonitor--daemon\n> > libcurl: 8.9.0\n> > OpenSSL: OpenSSL 3.2.2 4 Jun 2024\n> > zlib: 1.3.1\n> > uname: Windows 10.0 22631\n> > compiler info: gnuc: 14.1\n> > libc info: no libc information available\n> > $SHELL (typically, interactive shell): C:\\Program Files\\Git\\usr\\bin\\bash.exe\n> >\n> >\n> > [Enabled Hooks]\n> > not run from a git repository - no hooks to show\n> >\n"},{"id":"502426","messageId":"20fc64ed-24a1-45c0-928f-ddb4c6106262@gmail.com","threadId":"62043","inReplyTo":"CANrWfmS9PCKyK3X0rFnWfecrn-ETmcdtoPtA6j9QS7nTwfivKg@mail.gmail.com","subject":"Re: `git remote set-branches (without --add) <name> <branch>… ` does not add refspecs to `remote.<remote>.fetch` when `remote.<remote>.fetch` does not exist","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2024-09-09T09:13:23Z","receivedAt":"2024-09-09T09:13:28Z","isPatch":false,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 05/09/2024 23:24, Han Jiang wrote:\n> A way to get into the state is `git remote set-branches <remote>`\n> (followed by zero <branch>es), which removes `remote.server.fetch`\n> configuration variable.\n\nOh, I wonder if that is a feature or a bug? I see we don't sanity check \nthe branch name either so we'll happily create refspecs containing any \nold rubbish. I'll send a patch series that fixes the original bug and \nchecks the branch names later this week.\n\nBest Wishes\n\nPhillip\n\n> After that, `git remote set-branches <remote>\n> <branch>…` does not work. (But `git remote set-branches --add` can be\n> used to get out of the corrupted state.)\n> \n> Shortened version of the example:\n> git remote add server git@example.com\n> git config list --local\n> git remote set-branches server\n> git config list --local\n> git remote set-branches server branch1 branch2\n> git config list --local\n> \n> On Thu, Sep 5, 2024 at 9:07 PM Phillip Wood <phillip.wood123@gmail.com> wrote:\n>>\n>> On 03/09/2024 11:37, Han Jiang 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>>\n>> It is always helpful to show how to reproduce a bug but please try and\n>> aim for a minimal reproduction recipe. It is much easier to follow if\n>> you show which output lines come from which command. In this case one\n>> can reproduce the issue with\n>>\n>> $ git remote add test git@example.com\n>> $ git config --get-all remote.test.fetch\n>> +refs/heads/*:refs/remotes/test/*\n>> $ git config --unset-all remote.test.fetch\n>> $ git config --get-all remote.test.fetch\n>> $ git remote set-branches test main topic\n>> $ git config --get-all remote.test.fetch\n>>\n>> I haven't looked into what causes this. I wonder how likely users are to\n>> be affected - how did you get into a state where there was no fetch\n>> refspec set for your remote?\n>>\n>> Best Wishes\n>>\n>> Phillip\n>>\n>>> cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir \"$_\"; cd \"$_\";\n>>> mkdir --parents -- './server' './client';\n>>> git -C './client' init './repo'\n>>> git -C './client/repo' remote --verbose\n>>> git -C './client/repo' config list --local --show-scope --show-origin\n>>> git -C './client/repo' remote add server 'file://'\"$(realpath\n>>> './server/repo.git')\"\n>>> git -C './client/repo' remote --verbose\n>>> git -C './client/repo' config list --local --show-scope --show-origin\n>>> git -C './client/repo' remote set-branches server branch1 branch2\n>>> git -C './client/repo' config list --local --show-scope --show-origin\n>>> git -C './client/repo' remote set-branches --add server branch3 branch4\n>>> git -C './client/repo' config list --local --show-scope --show-origin\n>>> git -C './client/repo' remote set-branches --add server branch3 branch4\n>>> git -C './client/repo' config list --local --show-scope --show-origin\n>>> git -C './client/repo' remote set-branches server\n>>> git -C './client/repo' config list --local --show-scope --show-origin\n>>> git -C './client/repo' remote set-branches server branch1 branch2\n>>> git -C './client/repo' config list --local --show-scope --show-origin\n>>> git -C './client/repo' remote set-branches --add server branch3 branch4\n>>> git -C './client/repo' config list --local --show-scope --show-origin\n>>> git -C './client/repo' remote set-branches --add server branch3 branch4\n>>> git -C './client/repo' config list --local --show-scope --show-origin\n>>>\n>>> What did you expect to happen? (Expected behavior)\n>>>\n>>> (local config has branch1 and branch2:)\n>>> remote.server.fetch=+refs/heads/branch1:refs/remotes/server/branch1\n>>> remote.server.fetch=+refs/heads/branch2:refs/remotes/server/branch2\n>>> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n>>> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n>>> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n>>> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n>>>\n>>> What happened instead? (Actual behavior)\n>>>\n>>> (local config does not have branch1 and branch2:)\n>>> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n>>> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n>>> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n>>> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n>>>\n>>> What's different between what you expected and what actually happened?\n>>>\n>>> Anything else you want to add:\n>>>\n>>> Please review the rest of the bug report below.\n>>> You can delete any lines you don't wish to share.\n>>>\n>>>\n>>> [System Info]\n>>> git version:\n>>> git version 2.46.0.windows.1\n>>> cpu: x86_64\n>>> built from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d\n>>> sizeof-long: 4\n>>> sizeof-size_t: 8\n>>> shell-path: D:/git-sdk-64-build-installers/usr/bin/sh\n>>> feature: fsmonitor--daemon\n>>> libcurl: 8.9.0\n>>> OpenSSL: OpenSSL 3.2.2 4 Jun 2024\n>>> zlib: 1.3.1\n>>> uname: Windows 10.0 22631\n>>> compiler info: gnuc: 14.1\n>>> libc info: no libc information available\n>>> $SHELL (typically, interactive shell): C:\\Program Files\\Git\\usr\\bin\\bash.exe\n>>>\n>>>\n>>> [Enabled Hooks]\n>>> not run from a git repository - no hooks to show\n>>>\n"},{"id":"502556","messageId":"CANrWfmS4EHQU9pHH9t1kk6hq9E=W6uqi48CAvYgNnzSY-wkVTg@mail.gmail.com","threadId":"62043","inReplyTo":"20fc64ed-24a1-45c0-928f-ddb4c6106262@gmail.com","subject":"Re: `git remote set-branches (without --add) <name> <branch>… ` does not add refspecs to `remote.<remote>.fetch` when `remote.<remote>.fetch` does not exist","fromName":"Han Jiang","fromEmail":"jhcarl0814@gmail.com","sentAt":"2024-09-10T11:01:56Z","receivedAt":"2024-09-10T11:02:10Z","isPatch":false,"sender":{"key":"jhcarl0814@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5171262?v=4"},"body":"It's good to hear that the bug could get a fix! Looking forward to it!\nThe documentation does not say the expected behavior of that, so it's\nunder-specified whether it's a feature or a bug.\n\nOn Mon, Sep 9, 2024 at 9:13 PM Phillip Wood <phillip.wood123@gmail.com> wrote:\n>\n> On 05/09/2024 23:24, Han Jiang wrote:\n> > A way to get into the state is `git remote set-branches <remote>`\n> > (followed by zero <branch>es), which removes `remote.server.fetch`\n> > configuration variable.\n>\n> Oh, I wonder if that is a feature or a bug? I see we don't sanity check\n> the branch name either so we'll happily create refspecs containing any\n> old rubbish. I'll send a patch series that fixes the original bug and\n> checks the branch names later this week.\n>\n> Best Wishes\n>\n> Phillip\n>\n> > After that, `git remote set-branches <remote>\n> > <branch>…` does not work. (But `git remote set-branches --add` can be\n> > used to get out of the corrupted state.)\n> >\n> > Shortened version of the example:\n> > git remote add server git@example.com\n> > git config list --local\n> > git remote set-branches server\n> > git config list --local\n> > git remote set-branches server branch1 branch2\n> > git config list --local\n> >\n> > On Thu, Sep 5, 2024 at 9:07 PM Phillip Wood <phillip.wood123@gmail.com> wrote:\n> >>\n> >> On 03/09/2024 11:37, Han Jiang 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> >>\n> >> It is always helpful to show how to reproduce a bug but please try and\n> >> aim for a minimal reproduction recipe. It is much easier to follow if\n> >> you show which output lines come from which command. In this case one\n> >> can reproduce the issue with\n> >>\n> >> $ git remote add test git@example.com\n> >> $ git config --get-all remote.test.fetch\n> >> +refs/heads/*:refs/remotes/test/*\n> >> $ git config --unset-all remote.test.fetch\n> >> $ git config --get-all remote.test.fetch\n> >> $ git remote set-branches test main topic\n> >> $ git config --get-all remote.test.fetch\n> >>\n> >> I haven't looked into what causes this. I wonder how likely users are to\n> >> be affected - how did you get into a state where there was no fetch\n> >> refspec set for your remote?\n> >>\n> >> Best Wishes\n> >>\n> >> Phillip\n> >>\n> >>> cd '/'; cd '/'; rm --force --recursive -- './test_git'; mkdir \"$_\"; cd \"$_\";\n> >>> mkdir --parents -- './server' './client';\n> >>> git -C './client' init './repo'\n> >>> git -C './client/repo' remote --verbose\n> >>> git -C './client/repo' config list --local --show-scope --show-origin\n> >>> git -C './client/repo' remote add server 'file://'\"$(realpath\n> >>> './server/repo.git')\"\n> >>> git -C './client/repo' remote --verbose\n> >>> git -C './client/repo' config list --local --show-scope --show-origin\n> >>> git -C './client/repo' remote set-branches server branch1 branch2\n> >>> git -C './client/repo' config list --local --show-scope --show-origin\n> >>> git -C './client/repo' remote set-branches --add server branch3 branch4\n> >>> git -C './client/repo' config list --local --show-scope --show-origin\n> >>> git -C './client/repo' remote set-branches --add server branch3 branch4\n> >>> git -C './client/repo' config list --local --show-scope --show-origin\n> >>> git -C './client/repo' remote set-branches server\n> >>> git -C './client/repo' config list --local --show-scope --show-origin\n> >>> git -C './client/repo' remote set-branches server branch1 branch2\n> >>> git -C './client/repo' config list --local --show-scope --show-origin\n> >>> git -C './client/repo' remote set-branches --add server branch3 branch4\n> >>> git -C './client/repo' config list --local --show-scope --show-origin\n> >>> git -C './client/repo' remote set-branches --add server branch3 branch4\n> >>> git -C './client/repo' config list --local --show-scope --show-origin\n> >>>\n> >>> What did you expect to happen? (Expected behavior)\n> >>>\n> >>> (local config has branch1 and branch2:)\n> >>> remote.server.fetch=+refs/heads/branch1:refs/remotes/server/branch1\n> >>> remote.server.fetch=+refs/heads/branch2:refs/remotes/server/branch2\n> >>> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> >>> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> >>> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> >>> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> >>>\n> >>> What happened instead? (Actual behavior)\n> >>>\n> >>> (local config does not have branch1 and branch2:)\n> >>> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> >>> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> >>> remote.server.fetch=+refs/heads/branch3:refs/remotes/server/branch3\n> >>> remote.server.fetch=+refs/heads/branch4:refs/remotes/server/branch4\n> >>>\n> >>> What's different between what you expected and what actually happened?\n> >>>\n> >>> Anything else you want to add:\n> >>>\n> >>> Please review the rest of the bug report below.\n> >>> You can delete any lines you don't wish to share.\n> >>>\n> >>>\n> >>> [System Info]\n> >>> git version:\n> >>> git version 2.46.0.windows.1\n> >>> cpu: x86_64\n> >>> built from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d\n> >>> sizeof-long: 4\n> >>> sizeof-size_t: 8\n> >>> shell-path: D:/git-sdk-64-build-installers/usr/bin/sh\n> >>> feature: fsmonitor--daemon\n> >>> libcurl: 8.9.0\n> >>> OpenSSL: OpenSSL 3.2.2 4 Jun 2024\n> >>> zlib: 1.3.1\n> >>> uname: Windows 10.0 22631\n> >>> compiler info: gnuc: 14.1\n> >>> libc info: no libc information available\n> >>> $SHELL (typically, interactive shell): C:\\Program Files\\Git\\usr\\bin\\bash.exe\n> >>>\n> >>>\n> >>> [Enabled Hooks]\n> >>> not run from a git repository - no hooks to show\n> >>>\n"}]}