How to rename a git repo (project) which contains submodules in its subdirectories

前端 未结 4 1776
礼貌的吻别
礼貌的吻别 2021-02-12 14:34

I never expect renaming a git repo, which, more specifically, is the top-level folder holds the project, would be so hard. Yes, the project containing some submodules, but it is

4条回答
  •  旧时难觅i
    2021-02-12 15:35

    When moving a project that has git submodules from one folder to another, on the same machine, there are some hardcoded links that have to be updated.

    First, all submodules have a .git file where they store the absolute path to their git configuration folder ( these are inside the main's project .git folder, grouped into the modules folder). To fix all of these, run the following command from the root of the main project:

    find . -name .git -print0 -type f | xargs -0 sed -i 's|||g'
    

    Second, the configuration files for the git submodules have a line where the working directory is saved, also absolute. To update all of the references at once, run the following command from the root of the main project:

    find . -name config -print0 -type f | xargs -0 sed -i 's|||g'
    

    The assumptions made are that your OS is some form of *nix, and that you have the package sed installed.

提交回复
热议问题