[英]Make a folder both a symlink and a git submodule
This my project structure in a nutshell: 简而言之,这是我的项目结构:
+ A
| + some content
|
+ B
+ A
I want in my main git repo a submodule in B
that points to A
. 我想在我的主要git repo中找到B
中指向A
的子模块。 But since the A
project contains the main method, I want to be able to quickly test before committing, so I'd like a symlink (or rather a mklink
since I'm on windows) that points to A
so it gets updated without committing. 但是由于A
项目包含main方法,我希望能够在提交之前快速测试,所以我想要一个符号链接(或者更确切地说是一个mklink
因为我在Windows上)指向A
所以它得到更新而不提交。
The problem is that A doesn't have just "some content". 问题是A不仅仅是“一些内容”。
It also has a .git
subfolder in it, which a submodule does not. 它还有一个.git
子文件夹,子模块没有。
If you can, use git worktree
in order to checkout a branch in a separate folder (than the original A
cloned folder) 如果可以的话,使用git worktree
来检查单独文件夹中的分支(比原始的A
克隆文件夹)
Then you can try and use a symlink from B
subfolder to A
, after adding A
as a submodule in B
. 然后,在B
添加A
作为子模块后,您可以尝试使用B
子文件夹中的符号链接到A
Note: since Windows 10 build 14972 (Dec. 2016) , symlinks ( mklink
) can be created without needing to elevate the console as administrator. 注意: 自Windows 10 build 14972(2016年12月)起 ,可以创建符号链接( mklink
),而无需以管理员身份提升控制台。
A better approach is described in " Git: Possible to use same submodule working copy by multiple projects? ". “ Git:可能由多个项目使用相同的子模块工作副本? ”中描述了一种更好的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.