简体   繁体   English

将文件夹设置为符号链接和git子模块

[英]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.

相关问题 如何使用指向子模块中的文件夹的Windows符号链接正确克隆克隆 - How to properly git clone with Windows symlinks pointing to folder in submodule 如何在Windows的node_modules .bin文件夹中建立到命令的有效符号链接? - How do I make a working symlink to a command in my node_modules .bin folder on Windows? 链接到已安装的Windows文件夹的符号链接不起作用 - symlink to mounted windows folder not working 用于在Windows上进行符号链接转换的Git挂钩 - Git hooks for symlink convertion on Windows 当我尝试拖放包含git存储库(此时是子模块)的文件夹时,它会显示“无法将文件夹放到此处......” - When I try to drag and drop a folder which contains a git repository (which is a submodule at the moment) it says “Can't drop folder here…” 自动将更改上传到 git 子模块 - Upload changes to git submodule automatically 如何为 GIT 存储库中的文件创建符号链接 - how to create symlink for files in GIT repository Windows命令行检测路径中是否有SymLink文件夹 - Windows command line dectect if there is SymLink folder in path 如何在Windows上创建一个git repo的符号链接? - How to create to create a symlink of a git repo on windows?? 使用Windows上的Git将符号链接文件添加为文件 - Add symlink file as file using Git on Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM