方法四:使用 submodule 如果你希望在 Git 中添加一个真正的空目录,可以尝试使用 Git 的子模块(submodule)功能。子模块允许你将一个 Git 仓库作为子仓库嵌入到另一个 Git 仓库中,并且可以保持它们之间相互独立的版本控制。 1. 在你的主项目中,使用 git submodule add 命令将一个空的仓库作为子模块添加到主项目中...
arguments limit which submodules will be initialized. It will also copy the value of submodule.$name.update into .git/config. The key used in .git/config is submodule.$name.url. This command does not alter existing information in .git/config. You can then customize the submodule clone URLs...
$ git add empty_directory $ git commit -m “Add empty directory as submodule” “` 这样,空目录将作为子模块存在于父仓库中,并且可以跟踪并同步子模块的内容。 总结: 通过上述方法,可以在Git中模拟上传空目录的效果。选择合适的方法取决于你的具体需求。如果只是为了保留一个空目录的结构,你可以使用`.gitkee...
在project1中push之后其实就是更新了引用的commit id,然后project1-b在clone的时候获取到了submodule的commit id,然后当执行git submodule update的时候git就根据gitlink获取submodule的commit id,最后获取submodule的文件,所以clone之后不在任何分支上;但是master分支的commit id和HEAD保持一致。 查看~/submd/ws/project1...
2.1 创建Git Submodule测试项目 2.1.1 准备环境 1 2 3 ➜ henryyan@hy-hp ~pwd /home/henryyan mkdir-p submd/repos 创建需要的本地仓库: 1 2 3 4 5 cd~/submd/repos git --git-dir=lib1.git init --bare git --git-dir=lib2.git init --bare ...
TheDbConnectordirectory is there, but empty. You must run two commands:git submodule initto initialize your local configuration file, andgit submodule updateto fetch all the data from that project and check out the appropriate commit listed in your superproject: ...
$mkdirgit-submodule-demo $cdgit-submodule-demo/ $ git init Initialized empty Git repositoryin/Users/atlassian/git-submodule-demo/.git/ This sequence of commands will create a new directorygit-submodule-demo, enter that directory, and initialize it as a new repository. Next we will add a submo...
原来如此,.gitmodules记录了每个submodule的引用信息,知道在当前项目的位置以及仓库的所在。 好的,我们现在把更改提交到仓库。 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ➜ henryyan@hy-hp ~/submd/ws/project1git:(master) ✗ git comm...
say "$(eval_gettext "Cleared directory '\$displaypath'")" || say "$(eval_gettext "Could not remove submodule work tree '\$displaypath'")" fi mkdir "$sm_path" || say "$(eval_gettext "Could not create empty submodule directory '\$displaypath'")" #...
If the location of the .git directory matches the pattern, the include condition is met. The .git location may be auto-discovered, or come from $GIT_DIR environment variable. If the repository is auto-discovered via a .git file (e.g. from submodules, or a linked worktree), the .git...