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

troublesome branch name in remote repo causes .git/config inconsistency in cloned repo

From
PPPavel Pospíšil <pospispa@gmail.com>
Date
Jan 8, 2013, 18:30 UTC
Message-ID
<CADDfn-L_VWk5Rkn_P8aTf3pwBcbbYT=PZTrG=pFvJpNjgRg-5A@mail.gmail.com>

Hi, I think I came across a bug. I use git version 1.7.10.4 on Ubuntu 12.10. I haven't tried to find out if it's a known bug.

Reproduction scenario:
1. create a git repo:
$ mkdir -p tmp/bezdek
$ cd tmp/bezdek/
$ echo "*.swp" > .gitignore
$ git init
$ git add .
$ git commit -m "Initial commit"
2. clone the "remote" repo:
$ cd ../..
$ mkdir -p tmp/cloned
$ git clone ../bezdek/
3. create the troublesome branch in the "remote" repo
$ cd ../bezdek
$ git checkout -b
MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek
$ echo "*.bak" >> .gitignore
$ git add .
$ git commit -m "Some changes"
4. pull and checkout to the
MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek
branch in the cloned repo
$ cd ../cloned/bezdek
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = /home/pospispa/tmp/tmp/cloned/../bezdek/
[branch "master"]
        remote = origin
        merge = refs/heads/master
$ git pull
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects:  33% (1/3)
Unpacking objects:  66% (2/3)
Unpacking objects: 100% (3/3)
Unpacking objects: 100% (3/3), done.
From /home/pospispa/tmp/tmp/cloned/../bezdek
 * [new branch]
MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek
-> origin/MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek
Already up-to-date.
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = /home/pospispa/tmp/tmp/cloned/../bezdek/
[branch "master"]
        remote = origin
        merge = refs/heads/master
$ git checkout MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek
fatal: bad config file line 12 in .git/config
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = /home/pospispa/tmp/tmp/cloned/../bezdek/
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek"]
        remote = origin

I think that the problem may be with the branch name length. I think that git branch allows to created branches with very long names, however, such long name are not allowed in .git/config or the git checkout <very-long-remote-branch-name> has some problems with it.

I recovered from this problem in this way:
1. deleted last two lines in tmp/cloned/bezdek/.git/config file and
deleted index and working tree
$ git reset HEAD *
$ git checkout -- *
2. renamed the troublesome branch in "remote" repo:
$ cd ../../bezdek
$ git branch -m
MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek
MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek
3. pull from "remote" to cloned again
$ cd ../cloned/bezdek
$ git pull
From /home/pospispa/tmp/tmp/cloned/../bezdek
 * [new branch]
MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek ->
origin/MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek
Already up-to-date.
$ git branch -r
  origin/HEAD -> origin/master
  origin/MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek
  origin/MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek
  origin/master
$ git checkout MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek
Branch MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek
set up to track remote branch
MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek
from origin.
Switched to a new branch
'MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek'

Best regards, Pavel Pospisil

Next: Junio C Hamano
Message 1 of 2 in “troublesome branch name in remote repo causes .git/config inconsistency in cloned repo”
  1. Pavel PospíšilJan 8, 2013
  2. Junio C HamanoJan 8, 2013

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.