Git: How do I clone a subdirectory only of a Git repository?

前端 未结 18 2957
时光说笑
时光说笑 2020-11-21 04:33

I have my Git repository which, at the root, has two sub directories:

/finisht
/static

When this was in SVN, /finisht was chec

18条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-21 04:49

    This will clone a specific folder and remove all history not related to it.

    git clone --single-branch -b {branch} git@github.com:{user}/{repo}.git
    git filter-branch --subdirectory-filter {path/to/folder} HEAD
    git remote remove origin
    git remote add origin git@github.com:{user}/{new-repo}.git
    git push -u origin master
    

提交回复
热议问题