【问题标题】:PhpStorm: Won't receive changes of git submodule due to missing git remotePhpStorm:由于缺少 git 远程,不会收到 git 子模块的更改
【发布时间】:2022-08-16 18:05:39
【问题描述】:

我有三个项目(Main、Submodule、Test)。

我在Main(包含许多其他代码)和Test(为空)中添加了Submodule 项目作为git submodule。

之后,我在Submodule 项目中进行更改,提交并推送它们。

当我按下更新项目-Test 项目内我的 IDE (PhpStorm) 中的按钮,它获取项目的所有传入更改以及对 Submodule 项目所做的更改。

但是当我按下更新项目-Main 项目中的按钮,它只获取对项目的传入更改,但不会获取对Submodule 项目所做的更改。

git status 还表示在 Test 项目中使用时有更改,但在 Submodule 项目中使用时表示“最新”

Test 项目上的终端:

PS C:\Users\USERNAME\PhpstormProjects\Test> git status
On branch main
Your branch is up to date with 'origin/main'.

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

no changes added to commit (use "git add" and/or "git commit -a")
PS C:\Users\USERNAME\PhpstormProjects\Test>

Main 项目上的终端:

PS C:\Users\USERNAME\PhpstormProjects\Main> git status
On branch add-shared-repo                               
Your branch is up to date with 'origin/add-shared-repo'.
                                                           
nothing to commit, working tree clean                      
PS C:\Users\USERNAME\PhpstormProjects\Main>

有谁知道我做错了什么?如何使子模块保持最新?

更新:

我刚刚发现我的两个项目Main 和Test 之间存在差异。

在Test 项目中,“管理遥控器”窗口如下所示:

在Main 项目中,它看起来像这样:

我不知道为什么它没有像Test 项目中那样自动添加,但是对于那里的所有 PhpStorm 人,有谁知道如何将这些分组添加到遥控器中,就像第一张图片中一样“just-a -test”和“aar-shared”对应的遥控器?

当我尝试手动添加新的遥控器时,我可以添加名称(如来源)和 URL。

【问题讨论】:

  • 我认为你错过了子模块的一些东西。您必须将子模块更改提交到子模块中,然后您需要将子模块提交到存储库中。如果您不告诉 main 使用不同的子模块版本,那么对 main 来说一切都很好。您需要更新 main 中的子模块,然后提交 main
  • 您(或您的问题是否包括)“当我按下此按钮时,PHPStorm 到底在做什么,用 Git 术语来说?” (如果是这样,您需要询问 php-storm 人员,而不是 Git 人员。)
  • 感谢您的两个回答,但如上所述:它在测试项目中工作正常并且符合预期,并且在主项目中执行完全相同的操作时,它的行为不同并且不会得到子模块的更改。

标签: git phpstorm git-submodules


【解决方案1】:

更新 2:已解决

刚找到:

在Settings &gt; Version Control &gt; Directory Mappings 中,我需要添加一个新条目并选择项目内的子模块文件夹并将“VCS”设置为“Git”。

现在它就像在Test 项目中一样按预期工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-29
    • 1970-01-01
    • 2021-07-23
    • 2018-10-15
    • 2014-02-17
    • 2013-11-27
    • 2012-03-15
    • 1970-01-01
    相关资源
    最近更新 更多