V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cnt2ex
V2EX  ›  程序员

git 如何在一个父项目里管理目录重叠的两个 submodule

  •  
  •   cnt2ex · 141 天前 · 835 次点击
    这是一个创建于 141 天前的主题,其中的信息可能已经有所发展或是发生改变。

    场景:利用 git bare repo 来管理 dotfiles ,这里提到的。

    为了更方便的初始化 ohmyzsh ,把 ohmyzsh 作为 submodule 加入了进去:

    git--git-dir=$HOME/.cfg/ --work-tree=$HOME submodule add -b master https://github.com/ohmyzsh/ohmyzsh .oh-my-zsh

    同时,ohmyzsh 也包含了一些插件,比如 zsh-autosuggestions ,但是如果再通过 submodule add 加入,尝试

    git--git-dir=$HOME/.cfg/ --work-tree=$HOME submodule add -f -b master https://github.com/zsh-users/zsh-autosuggestions .oh-my-zsh/custom/plugins/zsh-autosuggestions

    (加上-f 是因为 ohmyzsh 的.gitignore 忽略了 custom/这个目录) 会报错:fatal: Pathspec '.oh-my-zsh/custom/plugins/zsh-autosuggestions' is in submodule '.oh-my-zsh'

    似乎 git 不允许两个 submodule 的目录重叠?有没有什么比较好的方法能处理这种情况呢?

    2 条回复    2023-12-21 18:21:49 +08:00
    zizon
        1
    zizon  
       141 天前   ❤️ 1
    repo 建个目录符号链 submodule 需要的部分?
    cnt2ex
        2
    cnt2ex  
    OP
       141 天前
    @zizon 试了一下,好像符号链接就行,虽然每次从其他机器 pull 都要手动创建符号链接。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1945 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:29 · PVG 00:29 · LAX 09:29 · JFK 12:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.