【问题标题】:git 2.18 win64, strange error when checking out branch, only in my PCgit 2.18 win64,签出分支时出现奇怪错误,仅在我的电脑中
【发布时间】:2019-01-22 19:14:00
【问题描述】:

这是一个奇怪的错误,我把步骤贴出来让你更好地理解:

PS C:\Users\user\Proyectos\GRV\Repos> git clone https://user@bitbucket.xxx.com/scm/in004/site-code.git in004_code

Cloning into 'in004_code'...
remote: Counting objects: 4034, done.
remote: Compressing objects: 100% (3565/3565), done.
remote: Total 4034 (delta 366), reused 4010 (delta 358)
Receiving objects: 100% (4034/4034), 10.11 MiB | 280.00 KiB/s, done.
Resolving deltas: 100% (366/366), done.
Checking out files: 100% (3577/3577), done.
PS C:\Users\user\Proyectos\GRV\Repos> cd .\in004_code\
PS C:\Users\user\Proyectos\GRV\Repos\in004_code> git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
PS C:\Users\user\Proyectos\GRV\Repos\in004_code> cat .\.gitmodules
[submodule "sites/default/files"]
        path = sites/default/files
        url = ../site-files.git
[submodule "profiles/hub"]
        path = profiles/hub
        url = ../../hub/hub-profile.git
        branch = 0.x
PS C:\Users\user\Proyectos\GRV\Repos\in004_code> git checkout int
fatal: bad config line 7 in file C:/Users/user/Proyectos/GRV/Repos/in004_code/.gitmodules
PS C:\Users\user\Proyectos\GRV\Repos\in004_code> cat .\.gitmodules
[submodule "sites/default/files"]
        path = sites/default/files
        url = ../site-files.git
[submodule "profiles/hub"]
        path = profiles/hub
        url = ../../hub/hub-profile.git
<<<<<<< HEAD
        branch = 0.x
=======
>>>>>>> 5580772... Initial commit qa
PS C:\Users\user\Proyectos\GRV\Repos\in004_code>

但这不会发生在我测试相同步骤的centos服务器中的同事身上。

有什么帮助吗?

【问题讨论】:

    标签: git


    【解决方案1】:

    次要编辑/更新:看起来默认情况下查看此错误的特定控制设置是recurse.submodules,它是在 Git 2.14 中引入的。早于 2.14 的 Git 版本将忽略任何 recurse.submodules=true 设置,而 2.14 及更高版本将服从它。看起来git checkout --no-recurse-submodules 没有在正确的时间清除标志可能存在错误。但是,git -c recurse.submodules=false checkout ... 应该可以通过。我认为失败本身——fatal: ... 中止结帐的退出——也是一个错误,但这不太清楚。


    许多 CentOS 发行版附带的 Git 版本很古老,无法检查错误情况。 (你没有说他们正在使用哪个 CentOS,也没有显示他们的 Git 版本,但是请参阅,例如,How to install latest version of git on CentOS 7.x/6.x 或更新的Can't clone any repository using git。在更新软件方面保守一点没有错,但是保守,然后有 CentOS...)

    您的实际存储库中有一个错误:.gitmodules 文件应该始终格式正确,但您的 int 分支的提示中的文件不是。您的 Git 是现代的,当您运行 git checkout int 时会立即发现问题。

    他们的 Git 很古老,所以当你查看那里的 int 分支时,他们的 Git 会悄悄地忽略这个问题。问题仍然存在那里,你只是没有得到投诉。该问题需要修复(通过修复.gitmodules 文件并在int 分支上进行新的提交)。

    【讨论】:

    • 具体来说,似乎有人没有正确修复冲突,大概是在合并或变基操作期间。 &lt;&lt;&lt; 很有说服力。看看 git blame 看看是谁干的。
    • @MadPhysicist 但我不明白为什么当我尝试切换到 int 分支时会弹出此错误,并且只有在我这样做之后文件才会更改。因为在 master 和 int 中,文件格式正确(见 Bitbucket web)。
    • @MadPhysicist 没关系,我看到它实际上被 int 破坏了
    • .gitmodules 文件是一个文件。因此,它在 每个 提交中(嗯,每个拥有该文件的提交——切换到一个 拥有该文件的提交,如果有的话,将 从您的工作树中删除文件)。 master 当前提示处的提交中的副本格式正确。 int 当前提示的提交中的副本格式错误。就像每个提交的文件一样,每个提交都有一个副本,但并非所有副本都相同!
    • 现在,如果我不能切换到 int 来制作 git checkout master .gitmodules 来带来好的,我该如何修复它? PS:我只是在问自己为什么在尝试切换分支失败后会有新文件,就像我添加它们一样。似乎在尝试失败后 repo 进入了损坏状态并且无法恢复。
    猜你喜欢
    • 2011-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-02
    • 1970-01-01
    • 2013-04-10
    相关资源
    最近更新 更多