git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Bug: duplicate sections in .git/config after remote removal

From
JFJason Frey <jfrey@redhat.com>
Date
Mar 27, 2018, 20:41 UTC
Message-ID
<CAP6Vx84GRRxgMZF5P6tb6F4rJ8ozxx-d0o_LsNe=kEYVRkBTKQ@mail.gmail.com>

While the impact of this bug is minimal, and git itself is not affected, it can affect external tools that want to read the .git/config file, expecting unique section names.

To reproduce:

Given the following example .git/config file (I am leaving out the [core] section for brevity):

    [remote "origin"]
        url = git@github.com:Fryguy/example.git
        fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
        remote = origin
        merge = refs/heads/master
Running `git remote rm origin` will result in the following contents:
    [branch "master"]

Running `git remote add origin git@github.com:Fryguy/example.git` will result in the following contents:

    [branch "master"]
    [remote "origin"]
        url = git@github.com:Fryguy/example.git
        fetch = +refs/heads/*:refs/remotes/origin/*

And finally, running `git fetch origin; git branch -u origin/master` will result in the following contents:

    [branch "master"]
    [remote "origin"]
        url = git@github.com:Fryguy/example.git
        fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
        remote = origin
        merge = refs/heads/master

at which point you can see the duplicate sections (even though one is empty). Also note that if you do the steps again, you will be left with 3 sections, 2 of which are empty. This process can be repeated over and over.

Thanks, Jason

Next: Stefan Beller
Message 1 of 8 in “Bug: duplicate sections in .git/config after remote removal”
  1. Jason FreyMar 27, 2018
  2. Stefan BellerMar 27, 2018
  3. Johannes SchindelinMar 28, 2018
  4. Ævar Arnfjörð BjarmasonMar 27, 2018
  5. Philip OakleyMar 28, 2018
  6. Philip OakleyMar 28, 2018
  7. Philip OakleyMar 28, 2018
  8. Philip OakleyMar 28, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.