新克隆的git仓库显示存在本地更改

5

我有点无法理解,为什么一个新克隆的git存储库显示有未暂存的更改。

这里是一个简短的例子:

    [dpetrov@macbook-pro ~/work]$ git clone /tmp/git/pollers.git pollers
    Cloning into 'pollers'...
    done.
    [dpetrov@macbook-pro ~/work]$ cd pollers/
    [dpetrov@macbook-pro ~/work/pollers (master)]$ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.

    nothing to commit, working tree clean
    [dpetrov@macbook-pro ~/work/pollers (master)]$ git checkout pollers-1.0
    gBranch pollers-1.0 set up to track remote branch pollers-1.0 from origin.
    Switched to a new branch 'pollers-1.0'
    i
    [dpetrov@macbook-pro ~/work/pollers (pollers-1.0)]$ git status
    On branch pollers-1.0
    Your branch is up-to-date with 'origin/pollers-1.0'.

    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   share/mibs/IANAifType-MIB.mib

    no changes added to commit (use "git add" and/or "git commit -a")
    [dpetrov@macbook-pro ~/work/pollers (pollers-1.0)]$ git diff share/mibs/IANAifType-MIB.mib
    diff --git a/share/mibs/IANAifType-MIB.mib b/share/mibs/IANAifType-MIB.mib
    old mode 100644
    new mode 100755
    index 3b4added..14da8028
    --- a/share/mibs/IANAifType-MIB.mib
    +++ b/share/mibs/IANAifType-MIB.mib
    @@ -1,13 +1,11 @@
    --- Extracted from http://www.iana.org/assignments/ianaiftype-mib
    ---
    -   IANAifType-MIB DEFINITIONS ::= BEGIN
    +IANAifType-MIB DEFINITIONS ::= BEGIN^M

   IMPORTS
        MODULE-IDENTITY, mib-2      FROM SNMPv2-SMI
        TEXTUAL-CONVENTION          FROM SNMPv2-TC;

    ianaifType MODULE-IDENTITY
-       LAST-UPDATED "200505270000Z"  -- May 27, 2005
+       LAST-UPDATED "200411220000Z"  -- June 17, 2004^M
        ORGANIZATION "IANA"
        CONTACT-INFO "        Internet Assigned Numbers Authority

有什么线索可以调试它,可能是什么原因引起的呢?非常感谢。

你检查过这些分支是否完全相同了吗?因为你是从'origin/master'克隆并切换到'origin/pollers-1.0',所以看起来分支之间的差异就是你看到的未暂存提交。 - Gabriel Rodrigues
@RômuloGabrielRodrigues 不是的,甚至在没有检出任何分支的主分支上也会发生这种情况。可能是在裸仓库中进行了错误的合并吗? - Dimitar Petrov
1
@DimitarPetrov,“即使在主分支上也会发生这种情况”是什么意思? 在这个例子中,我们可以看到主分支上没有任何更改
没有要提交的内容,工作树干净
- Rumid
你也看过这些解决方案吗: https://dev59.com/MWUq5IYBdhLWcg3wXvMC https://dev59.com/sG025IYBdhLWcg3wzZT3 ? - Rumid
这不是重复的,因为这两个文件是不同的:所以你有 example.xml 和 ExamPLE.xml 这两个不同内容的文件。根据文件系统,它们可能会显示为差异或正常显示。我在提交工单时没有发现这一点的原因是我在远程运行 Linux 的机器上进行测试,后来在我的 Mac 上进行了测试。我相当确定我在 stackoverflow 上找到了答案,所以将其标记为重复。 - Dimitar Petrov
显示剩余4条评论
1个回答

0

这是一个文件名大小写敏感的问题:两个不同的文件,只有名称大小写不同,在git中被存储。

在检查差异时,git会接收到其中一个名称的“错误”内容。


旧问题,在评论中自我回答。只是添加一个帖子来说明“有答案”。 - LeGEC

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接