How to commit a git repository inside another git repository

前端 未结 3 1013
甜味超标
甜味超标 2021-01-17 16:32

I\'m developing an application that uses git, so I need to test its integration with git. Inside my git repository, I need to have another repository (my_git_repo/tests/anot

3条回答
  •  死守一世寂寞
    2021-01-17 16:56

    Submodules don't necessarily need to be cloned separately; you can publish a project and its submodules in a single repo. Just have a branch dedicated to the submodule contents in your main repo, then after cloning the main repo git clone -sb the submodule directly from there.

    # setup your current repo this way:
    ( git init sub
      cd sub
      > file
      git add .
      git commit -m-
      git remote add origin ..
      git push -u origin master:sub/master
    )
    

    Setup in new clone:

    git branch -t sub/master origin/sub/master
    git clone -sb sub/master . sub 
    

    and sub will have the most recent content.

    git rev-parse :sub will show you what's committed for sub -- i.e. what should be checked out there -- when you don't just want the current branch tip.

    You could hook up the git submodule command here, with a .gitmodules file and this and that, but it hardly seems worth it.

提交回复
热议问题