Search code examples
gitgit-submodules

Using submodules with bare repository fails


I'm following this guide for storing dotfiles. I pushed all my dotfiles from my first computer, including submodules. I added submodules like this:

config submodule add https://github.com/Aloxaf/fzf-tab .cache/zsh/plugins/fzf-tab,

where alias config='/usr/bin/git --git-dir=$XDG_CONFIG_HOME/cfg --work-tree=$HOME.

After cloning my repo in $HOME/cfg on destination computer with git clone --bare --recursive my-repo-ssh .config/cfg , and doing config checkout and then config submodule update --recursive, i get message "cloning into home/user/.cache/zsh/plugins/fzf-tab which I thought is good.

But, in .cache/zsh/plugins/fzf-tab directory there is only .git file with one line: ../../../../.config/cfg/modules/.cache/zsh/plugins/fzf-tab (it's the place where I cloned the bare repository).

Why is this happening? I couldn't find anywhere how to use submodules properly with bare repos. Thanks in advance.


Solution

  • Fixed it with:

    git clone --bare --recurse-submodules my-repo-ssh .config/cfg
    config checkout -f
    config submodule update --init --recursive