Git treat nested git repos as regular file/folders

后端 未结 1 1947
北恋
北恋 2020-12-19 05:51

I have a top level git repo organized like so:

  • .git/
  • repoA/
    • .git/
    • file
    • file2
    • folder/
    • ...
相关标签:
1条回答
  • 2020-12-19 06:06

    You can look into git subtree.

    For that, if you currently have submodules, you can follow "Convert a git repository from submodules to subtrees":

    cat .gitmodules |while read i
    do
      if [[ $i == \[submodule* ]]; then
        mpath=$(echo $i | cut -d\" -f2)
        read i; read i;
        murl=$(echo $i|cut -d\  -f3)
        mcommit=`eval "git submodule status ${mpath} |cut -d\  -f2"`
        mname=$(basename $mpath)
        echo -e "$name\t$mpath\t$murl\t$mcommit"
        git submodule deinit $mpath
        git rm -r --cached $mpath
        rm -rf $mpath
        git remote add $mname $murl
        git fetch $mname
        git branch _$mname $mcommit
        git read-tree --prefix=$mpath/ -u _$mname
    fi
    done
    git rm .gitmodules
    

    (test it on a copy of your repo first)

    See also "When to use git subtree?", which differs from ingydotnet/git-subrepo.

    0 讨论(0)
提交回复
热议问题