我在 Bitbucket.org 上有一个功能良好的 git 存储库。\n但是,我有一个目录似乎不受我的存储库的控制。
\n\n每当我推送更改时,该目录中的所有内容都会被留下。如果我将存储库克隆到新位置,该目录会显示,但它是空的。
\n\n我认为目录内容是从另一个项目中提取的,可能是在另一个 git 存储库中(我不是编码该项目的这一特定部分的人) - 也许这是有联系的?
\n\n当我在 Bitbucket 中查看这部分存储库的列表时,该目录显示如下:\ncommerce_shipworks \xe2\x86\x92 eb549bd63c0b [eb549bd63c0b]
\n\n这是否意味着它指向我未连接到的其他某个分支?\n底线 - 我怎样才能重新获得对这批代码的控制?
\n\n任何帮助表示赞赏。
\n考虑一个 git 存储库 Foo/,它有子模块 bar1/ 和 bar2/。
其中每一个都有相同的分支:1 和 2。
我进入超级模块,并且想要更新超级模块以包含 bar1 和 bar2 来源的最新提交。我已经初始化并更新了超级模块,因此 bar1 和 bar2 中有工作树,但它们处于分离状态。我可以执行以下操作:
cd foo;
git checkout 1
git submodule foreach git checkout 1
git pull
Run Code Online (Sandbox Code Playgroud)
现在,令我烦恼的是重复分支标识符。我可以做类似“git submodule foreach git checkout $CURRENT_BRANCH_ID”之类的事情吗?有更好的选择吗?
团队服务文档(https://www.visualstudio.com/en-us/docs/build/define/repository#what-kinds-of-submodules-can-i-check-out)指出我可以做一个$ git add submodule如果
他们举了一个例子:
git submodule add /../../submodule.git mymodule
Run Code Online (Sandbox Code Playgroud)
如果我在同一个项目中引用 git 存储库,例如
git submodule add ./../other-repo mymodule
Run Code Online (Sandbox Code Playgroud)
它解决了正确的回购协议,但希望我提供凭据。构建失败并显示以下消息:
Cloning into 'mymodule'...
fatal: could not read Username for 'https://xxx.visualstudio.com': Invalid argument
Run Code Online (Sandbox Code Playgroud)
提供带有凭据的完整 URL ( https://user:password@xxx.visualstudio.com/.. ) 可以,但在我看来是一个糟糕的解决方案。
该文档建议这应该适用于相对 url 并且无需凭据。我错了吗?
使用 system.debug 运行: true
Entering OnPrepareEnvironment
Primary repository: xxx
Calculating build folder hash key.
Loading tracking config if exists: C:\a\SourceRootMapping\07a8b96d-d805-4646-83d3-e7b2fbe394c2\18\SourceFolder.json
Creating new tracking config.
Loading top-level tracking config …Run Code Online (Sandbox Code Playgroud) 在 Git 中,我在模块 A 中有子模块 B。我想转到 B 中的特定提交,然后使用 B 的特定提交(如果有)在 A 中查找相应的提交。例如,使用特定 B 版本的 A 的最新提交就可以。这个怎么做 ?
我添加了一些 git 子模块,它们在 .gitmodules 中配置。我对子模块的特定提交感兴趣。因此,我提交了这些提交,并且可以在 git 子模块状态中看到。说是为了
[submodule "pcl"]
path = libs/pcl
url = https://github.com/PointCloudLibrary/pcl.git
Run Code Online (Sandbox Code Playgroud)
子模块状态显示757e28a75a0c6c0413085a2af070670828a48527libs/pcl。这意味着运行后将检查上述 SHA1git submodule update --init
但是,我的问题是我不想完全克隆子模块 pcl,因为我只对 757e28a75a0c6c0413085a2af070670828a48527 以后的提交感兴趣。有没有办法通过在 .gitmodules 文件中写入深度参数等来实现此目的?
我看过几篇文章,但大多数都建议做一个 git add 子模块。既然我已经这样做了,有没有办法用每个子模块的深度参数来编辑 .gitmodule 文件。
git clone --depth 10 --shallow-submodules <repo>
Run Code Online (Sandbox Code Playgroud)
在我看来,会拉取主分支的 10 次提交,然后拉取所有子模块的主分支的提示。我的理解正确吗?
我有几个项目,每个项目都有自己的存储库,它们导入一个公共库,该库也有自己的存储库。因此,该.gitmodules文件包含全名的库:
Submodule 'xx/yy' (https://gitlab.com/xx/yy.git) registered for path 'xx/yy'
Run Code Online (Sandbox Code Playgroud)
但这不起作用:
Fatal: could not read Username for 'https://gitlab.com': No such device or address
Run Code Online (Sandbox Code Playgroud)
CI 脚本非常简单:
image: mcr.microsoft.com/dotnet/core/sdk:3.0.100-preview9-alpine3.9
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- build
before_script:
- "cd xx"
- "dotnet restore"
build:
stage: build
script:
- "cd xx"
- "dotnet build"
Run Code Online (Sandbox Code Playgroud)
旧的答案是: GitLab pull submodules inside CI
但事情已经改变,根据文档,我们可以拥有没有相对路径的子模块,如下所示: https: //docs.gitlab.com/ce/ci/git_submodules.html
我有一个 GitHub 存储库,我将其作为另一个存储库的子模块克隆到我的计算机上。
我在本地拥有所有文件和提交,但在远程,我的 git 客户端认为没有任何分支。(git branch -r什么也没显示)
git fetch origin给出这个结果:
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch origin
From https://github.com/Estecka/ChainMaths
* branch HEAD -> FETCH_HEAD
Completed successfully.
Run Code Online (Sandbox Code Playgroud)
但实际上,我仍然没有找到任何分支。
尝试推送我的本地更改成功,我可以看到我的更改反映在 GitHub 网站上,但即使如此,我的 git 客户端仍然无法在远程找到任何分支,即使是刚刚推送的分支。
这不是我第一次遇到子模块的问题,而且我从未在经典存储库中遇到过它。
我们的项目使用 git子模块来固定我们的库依赖项之一。
我们定期rebase将子模块跟踪上游更改,并且我们在它上面还有一组我们不能轻易上游的提交。
当有人重新设置子模块时,我只git diff在父存储库中看到这一点:
--- a/mysubmodule
+++ b/mysubmodule
@@ -1 +1 @@
-Subproject commit abc12345abc12345abc12345abcd12345abc1234
+Subproject commit efg67890efg67890efg67890efg67890efg67890
Run Code Online (Sandbox Code Playgroud)
那不是很有用。当我git diff在子模块中提交这些提交时,我会得到很多输出,包括所有上游更改,我们的提交位于顶部。我无法轻易判断对我们自己的提交执行的某些冲突解决是否引入了一些错误。
如何有效地对子模块的更改进行代码审查?
我在 AWS Codecommit 中有两个存储库,我想将一个存储库作为子模块添加到其他存储库中。这两个 repos 位于一个角色中,而不是在 root 帐户中
.gitmodules(Repo1 中的文件)
[submodule "submodule"]
path = sub/module
url = codecommit://Repo2
Run Code Online (Sandbox Code Playgroud)
和
git submodules update
Run Code Online (Sandbox Code Playgroud)
我得到
fatal: transport 'codecommit' not allowed
fatal: clone of 'codecommit://Repo2' into submodule path 'sub/module' failed
Run Code Online (Sandbox Code Playgroud)
而且我无法使用 HTTPS,因为我不知道如何使用 HTTPS 切换角色。我将不胜感激任何建议
操作系统:Linux
git 版本:2.26.2
我的仓库的 Git 仓库提供者:gitlab
失败子模块的回购提供者:Github
.gitmodules
[submodule "libraries/stb"]
path = libraries/stb
url = https://github.com/nothings/stb.git
branch = master
[submodule "libraries/harfbuzz"]
path = libraries/harfbuzz
url = https://github.com/harfbuzz/harfbuzz.git
branch = master
[submodule "libraries/shaderc"]
path = libraries/shaderc
url = https://github.com/google/shaderc.git
branch = master
[submodule "libraries/freetype2"]
path = libraries/freetype2
url = https://github.com/aseprite/freetype2.git
branch = master
[submodule "libraries/VulkanMemoryAllocator"]
path = libraries/VulkanMemoryAllocator
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
branch = master
[submodule "libraries/googletest"]
path = libraries/googletest
url = https://github.com/google/googletest.git
branch = master
[submodule "libraries/Eigen"]
path = libraries/Eigen
url …Run Code Online (Sandbox Code Playgroud) git-submodules ×10
git ×9
gitlab ×2
azure-devops ×1
git-diff ×1
git-fetch ×1
github ×1
gitlab-ci ×1
linux ×1