解决问题:通过子模块显示外部代码依赖性:感谢VonC!
当前问题:在两个文件夹中有一个没有重复内容的子模块
当前问题的临时解决方案:将文件夹的名称更改为bin-github,因为作为子模块的文件夹的名称是bin.这意味着我需要在我的家中复制内容.
我的HOME文件夹依赖于〜/ bin.我的文件位于主页的存储库Masi,而位于Github 的repo bin的〜/ bin .我家的相关文件夹结构:
~
|-- [drwxr-xr-x] bin
| -- fileA
` -- folderA
...
Run Code Online (Sandbox Code Playgroud)
我想知道如何在Masi上显示make~/bin是Git的一个子模块.
你怎么能〜/ bin中的〜/ bin是我的Git的一个子模块?
#3回复VonC的评论:
我的.gitmodules
[submodule "bin"]
path = bin
url = git://github.com/masi/bin.git
Run Code Online (Sandbox Code Playgroud)
我觉得我不需要再添加子模块了,因为我已经在我的.gitmodules中了.
我跑
Sam master $ git submodule update
Sam master $ git submodule foreach git pull
Sam master $ ls bin
Run Code Online (Sandbox Code Playgroud)
#2回复VonC的回答:
我将.gitmodules更改为以下内容,以便在我的家中没有它的副本.
[submodule "bin"]
path = bin
url = git://github.com/masi/bin.git
Run Code Online (Sandbox Code Playgroud)
这似乎是一个不同的情况,因为我不能像上面那样拉动子模块bin文件夹.
我现在在一个新克隆的git-repo上得到以下内容 …
我有一个大目录~/.vim,在其中我有一个子目录,其中有许多其他git回购.我想制作我的~/.vim目录的git repo ,但不想浏览我的其他git子目录.
有没有办法只递归通过并添加所有子模块?
问题
我正在尝试在Jenkins中构建我的应用程序,它在Github上的私有仓库中,也有一个私有子模块.
我可以通过设置它的凭据克隆Jenkins中的私有存储库,但是Jenkins无法克隆子模块,这是失败构建的输出:
Started by an SCM change
Building in workspace /var/lib/jenkins/jobs/Project/workspace
Fetching changes from the remote Git repository
Fetching upstream changes from git@github.com:user/repogit
using GIT_SSH to set credentials
Checking out Revision 9cc99b67cc676d0ea8ccd489a8327f5c6dbb8d7f (origin/branch)
[workspace] $ /bin/sh -xe /tmp/hudson2710403018107019432.sh
+ git submodule update --init --recursive
Initialized empty Git repository in /var/lib/jenkins/jobs/repository/submodule/.git/
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
Clone of 'git@github.com:user/submodule.git' into submodule path 'repository/submodule/' failed
Build step 'Execute shell' marked build as failure
Discard old …Run Code Online (Sandbox Code Playgroud) 在阅读了关于子模块的这篇文章后,它们似乎只是为了从您自己的内部链接到外部 git 存储库而存在。但是,我希望子模块能够让您从一个存储库中管理多个单独的提交历史记录。
是否可以拥有非外部 git 存储库?我想在一个存储库下管理我所有的厨师食谱,每个库都有单独的提交历史,而无需创建一堆 git 存储库
编辑:我认为我没有明确说明我的用例。我的意思是我想在唯一可寻址的地方为我的每个服务器提供食谱列表;并不是我想要一个单独的食谱的子模块。在这种情况下,mu 的回答非常有效地解决了这个问题。
如何在本地存储库中使用 TortoiseGit 创建子模块?以及如何将创建的子模块推送到主 Git 存储库?
我有一个带有多个git submodules的主存储库。
最近我遇到了一个我无法解决的新错误:
fatal: Could not switch to '~/git': No such file or directory
Clone of '~/git/MyModule_A.git' into submodule path '.modman/MyModule_A' failed
Run Code Online (Sandbox Code Playgroud)
首先,我像往常一样克隆主仓库: git clone /path/to/the/bare/repo.git src
然后,我运行git submodule update --init它确实正确注册了所有子模块并将它们添加到.git/config.
Submodule '.modman/MyModule_A' (~/git/MyModule_A.git) registered for path '.modman/MyModule_A'
Submodule '.modman/MyModule_B' (~/git/MyModule_B.git) registered for path '.modman/MyModule_B'
Submodule '.modman/MyModule_C' (~/git/MyModule_C.git) registered for path '.modman/MyModule_C'
fatal: Could not switch to '~/git': No such file or directory
Clone of '~/git/MyModule_A.git' into submodule path '.modman/MyModule_A' failed
Run Code Online (Sandbox Code Playgroud)
MyModule_A …有很多关于稀疏结账的文章和问题。不幸的是我没有找到具体的例子。我想让以下示例工作:
cd ~
mkdir sub && cd $_
git init
mkdir foo && touch $_/foo
mkdir bar && touch $_/bar
git add .
git commit -am "Initial commit"
Run Code Online (Sandbox Code Playgroud)
cd ~
mkdir project && cd $_
git init
git submodule add ../sub sub
git config -f .gitmodules submodule.sub.shallow true
git config -f .gitmodules submodule.sub.sparsecheckout true
echo foo/* > .git/modules/sub/info/sparse-checkout
git commit -am "Initial commit"
git submodule update
cd sub
git checkout .
Run Code Online (Sandbox Code Playgroud)
在这一点上,我希望sub文件夹只包含foo/foonot bar。不幸的是它不起作用: …
我只是不明白 Git 的帮助页面。那么会发生什么或者有什么区别?
假设我有一个带有子模块 B 的 Git 项目 A。子模块 B 确实有一个子模块 C。克隆存储库后,A 指向 B 的特定提交。B 指向 C 的特定提交。
如果我在 AI 里面去 B
cd B
Run Code Online (Sandbox Code Playgroud)
现在我输入
git submodule update --remote
Run Code Online (Sandbox Code Playgroud)
或者
git submodule update
Run Code Online (Sandbox Code Playgroud)
有什么不同?假设远程服务器的 A、B 和 C 确实有变化。
我想使用“git submodule update --remote”会保留对特定版本的 C 的引用。是否在不--remote更新到最新版本的 C 的情况下使用它?
今天,我开始收到来自 git 的新警告,这是我以前从未见过的关于我的子模块的警告。例如:
warning: <hash_omitted>:.gitmodules, multiple configurations found for 'submodule.foo/bar'. Skipping second one!
Run Code Online (Sandbox Code Playgroud)
快速搜索似乎没有返回任何相关信息。我看到这里生成了警告,听起来可能与工作树有关?
这个警告究竟意味着什么,它的解决方案是什么?
我安装我的Plesk网站所描述的通过后钩自动拉从远程仓库更改Web服务器的某个路径这里。
但是,我的存储库包含一个 git 子模块,我还需要运行自定义命令git submodule update --remote。我怎么能告诉 plesk 这样做。我可以输入的命令
启用其他部署操作
设置似乎没有在正确的路径中执行。此外,当我转到存储库在我的服务器上同步到的路径时,我得到:
fatal: Not a git repository (or any of the parent directories): .git
我怎样才能告诉 plesk 也使用 git 插件更新子模块?
git ×10
git-submodules ×10
chef-infra ×1
git-worktree ×1
github ×1
jenkins ×1
jenkins-php ×1
php ×1
plesk ×1
tortoisegit ×1