V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
UnrealEngine
V2EX  ›  git

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

  •  
  •   UnrealEngine · 2020-07-06 22:12:27 +08:00 · 2723 次点击
    这是一个创建于 1362 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

    但是改动文件实在太多

    如果 add 的时候每个文件都要 git add {file}那岂不是很麻烦?
    noqwerty
        3
    noqwerty  
       2020-07-06 23:04:03 +08:00 via Android
    @UnrealEngine 你就算 git add --all 了再把 submodule 从 staged 的文件里去掉不就好了,用 git restore
    ashmodeus
        4
    ashmodeus  
       2020-07-06 23:27:37 +08:00
    不要初始化 submodule 就好了,submodule 部署时使用。
    自己开发机需要部署,可以通过软链等其他形式。
    opiviqo
        5
    opiviqo  
       2020-07-07 13:59:05 +08:00
    git add -u?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2838 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 14:31 · PVG 22:31 · LAX 07:31 · JFK 10:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.