git
› Pro Git
› Atlassian Git Tutorial
› Pro Git 简体中文翻译
› GitX
UnrealEngine
V2EX  ›  git

git 提交的时候,如何避免子模块 submodule 也跟着一块提交上去?

  •  
  •   UnrealEngine · Jul 6, 2020 · 3998 views
    This topic created in 2311 days ago, the information mentioned may be changed or developed.

    主模块是 PHP 代码,子模块是一些前端文件(只有前端程序员会改动),我改动的代码只有主模块的文件,而且 git status 的时候确实没动到子模块的文件,但是我 commit 和 push 之后会与 master 分支里的 submodule 冲突,git log 后发现我子模块里的 commit 发生变化了,请问要如何处理才好?

    5 replies  •  2020-07-07 13:59:05 +08:00
    classyk
    classyk
    Jul 6, 2020
    1
    不要 add 子模块
    UnrealEngine
    UnrealEngine
    OP
    Jul 6, 2020
    2
    @classyk 在主模块下 git status 时确定子模块并没有改动,是否是因为 git add . 而把子模块也加了进来?

    但是改动文件实在太多

    如果 add 的时候每个文件都要 git add {file}那岂不是很麻烦?
    noqwerty
    noqwerty
    Jul 6, 2020 via Android
    3
    @UnrealEngine 你就算 git add --all 了再把 submodule 从 staged 的文件里去掉不就好了,用 git restore
    ashmodeus
    ashmodeus
    Jul 6, 2020
    4
    不要初始化 submodule 就好了,submodule 部署时使用。
    自己开发机需要部署,可以通过软链等其他形式。
    opiviqo
    opiviqo
    Jul 7, 2020
    5
    git add -u?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1434 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 22:00 · PVG 06:00 · LAX 14:00 · JFK 17:00
    ♥ Do have faith in what you're doing.