V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
UnrealEngine
V2EX  ›  git

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

  •  
  •   UnrealEngine · Jul 6, 2020 · 3606 views
    This topic created in 2132 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
        1
    classyk  
       Jul 6, 2020
    不要 add 子模块
    UnrealEngine
        2
    UnrealEngine  
    OP
       Jul 6, 2020
    @classyk 在主模块下 git status 时确定子模块并没有改动,是否是因为 git add . 而把子模块也加了进来?

    但是改动文件实在太多

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