从本地工作目录目录创建
- 本地创建
git init
git add .
git commit -m ""
touch .gitignore
- 在github上创建空的repository,并拷贝对应的地址repository-url
- 连接本地工作目录与远程url
git remote add origin remote repository-url
git remote -v
git push -u origin master
从github创建
- 在github上创建空的repository,并拷贝对应的地址repository-url
- 本地创建
git clone repository-url
git touch
git add
git commit
git push
在git库的工作目录下添加新的git库工作目录
https://github.blog/2016-02-01-working-with-submodules/
- 进入当前工作目录下的子目录
cd subDir
git submodule add subRepository-url newDir
基于工作目录下子目录创建新的git库
https://help.github.com/en/github/using-git/splitting-a-subfolder-out-into-a-new-repository
- 拆分工作目录
git clone repository-url
cd repository-dir
git filter-branch --prune-empty --subdirectory-filter FOLDER-NAME BRANCH-NAME (master or gh-pages)
- 在github上创建repository,并拷贝repository-url
- 连接本地子目录和新的repository
git remote -v
git remote set-url origin new-repository-url (更新子目录关联的repository)
git remote -v
git push -u origin BRANCH-NAME
参考
https://www.git-tower.com/learn/git/ebook/en/command-line/advanced-topics/submodules