在我们的git-svn托管项目中,我们有3个上游项目都保存在GitHub上的本机git存储库中.由于这些上游项目的源代码在我们的控制和频繁变化之下,我们当前的解决方案,即每次我们改变某些东西时将构建工件重新部署到超级项目都是非常麻烦的.
我想拥有的是:
parent project (git-svn):
--> submodule 1 (git)
--> submodule 2 (git)
--> submodule 3 (git)
Run Code Online (Sandbox Code Playgroud)
这样,子模块1-3的源代码与超级项目的源一起编译,但我可以单独将更改推送到子模块.
问题是:当我git svn dcommit在父项目上时会发生什么?这甚至有用吗?
更新 嗯,我只是设置了一个简单的项目结构,尝试类似于这个场景,并且在尝试在超级项目上进行dcommit时收到此错误消息:
a0301b11f3544a1e71067ff270eded65e4c8afbd doesn't exist in the repository at /opt/local/libexec/git-core/git-svn line 4775
Failed to read object a0301b11f3544a1e71067ff270eded65e4c8afbd at /opt/local/libexec/git-core/git-svn line 574
Run Code Online (Sandbox Code Playgroud)
有什么想法/建议吗?
假设以下项目布局: -
mainrepo_git
|____ .git
|____ .gitmodules
|____ proj <------- directory containing the code files for mainrepo
|____ 3rdpartysourcecode <-- directory containing upstream open source code
| |____ .git
| |____ 3rdpartyfiles
|
|____ mainrepofilesanddirectories
Run Code Online (Sandbox Code Playgroud)
mainrepo_git包含我直接负责的源代码.我有读/写访问权限,可以直接推送到我管理的远程git存储库.
嵌套在mainrepo_git中的是一个名为3rdpartysourcecode的目录.这个3rdpartysourcecode目录实际上是另一个git repo(通常也称为"git submodule"),它指向由其他开发人员管理的开源第三方git存储库.我只有读取权限.没有写访问权限.
有没有办法'冻结'git子模块的特定提交哈希与我的主存储库中提交的相关?
例如,如果我在(或我恢复)在我的mainrepo中提交a12ucak,我的git子模块也会被恢复为特定版本,我将其绑定为提交a12ucak?当我切换到提交b349jdsak时,我的git子模块也会恢复到我绑定到b349jdsak的版本?
所以我的问题是:有一种方法可以在主仓库中的特定提交与git子模块中的相应提交之间创建链接吗?以这种方式,当我在主git repo中检出特定提交时,git子模块中的相应提交也将是checkout.
我有我的项目+ RestKit子模块.我更改了RestKit设置时出现错误.我添加了支持armv6和armv7架构.
git add .
git add -u
git commit -m "new"
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# (commit or discard the untracked or modified content in submodules)
#
# modified: RestKit (modified content)
#
Run Code Online (Sandbox Code Playgroud)
如何解决此错误.
更新:我没有运行git add RestKit.
UPDATE2:我项目的结构是:

我添加了子模块作为
git submodule update -i
Run Code Online (Sandbox Code Playgroud) 我有一个包含两个子模块的存储库,我想将其转换为单个项目.许多答案涉及脚本,有些似乎过于复杂.
[submodule "site"]
path = wp-content/themes/site
url = https://ajf-@bitbucket.org/ajf-/site.git
fetchRecurseSubmodules = true
ignore = all
[submodule "wpsite"]
path = wp-content/themes/wpsite
url = https://ajf-@bitbucket.org/ajf-/wpsite.git
fetchRecurseSubmodules = true
ignore = all
Run Code Online (Sandbox Code Playgroud)
是否有正式支持/记录的方法将这些子模块合并到父存储库中?
我有两个分支A和B.两者都包含一个子模块(在文件夹中sub),但是在不同的提交中(不会从一个快进到另一个).
A B
| /
BASE
Run Code Online (Sandbox Code Playgroud)
我已经检查过A,但子模块尚未初始化.现在我合并B,我在子模块上发生冲突.
$ git status
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: sub
Run Code Online (Sandbox Code Playgroud)
发布git checkout --ours sub什么都不做(如果子模块初始化它有效,也git checkout-index -f --stage=2 -- sub不起作用).git add sub导致错误error: pathspec 'sub' did not match any file(s) known to git..
$ git diff sub
diff --cc sub
index 533da4e,ab2af77..0000000
--- a/sub
+++ b/sub
@@@ -1,1 -1,1 +1,1 @@@
- …Run Code Online (Sandbox Code Playgroud) 如何将git子模块(本地文件系统中的文件夹作为远程)转换为git子树,最好保留子模块的提交历史记录?
我有一个使用git子模块的项目.在我的python文件中,我想使用子模块项目中另一个python文件的函数.
为了工作,我必须将init .py文件添加到路径中的所有子文件夹.我的文件夹树如下:
myproj
??? gitmodules
? ??? __init__.py
? ??? __init__.pyc
? ??? mygitsubmodule
? ??? __init__.py
? ??? __init__.pyc
? ??? file.py
??? myfile.py
Run Code Online (Sandbox Code Playgroud)
有没有办法让它工作而不触及mygitsubmodule?
谢谢
我发现使用git子模块时,我经常遇到在包含给定子模块的提交和代表与普通目录相同的代码的提交之间合并的问题.小型复制示例:
# Create one project, to be used as a subproject later on
git init a
cd a
echo aaa > aa
git add -A
git commit -m a1
cd ..
# Create a second project, containing a as a normal directory initially
git init b
cd b
mkdir a b
echo aaa > a/aa
echo bbb > b/bb
git add -A
git commit -m b1
# Replace directory with submodule
git rm -r a
git submodule add ../a a …Run Code Online (Sandbox Code Playgroud) 我有两个遥控器git存储库(github和bitbucket).在里面我有子模块,相应地指向另一个github/bitbucket repo.但是在submodule的定义是url,那就是硬编码.我可以有两个吗?或者每个遥控器一个?所以我在github上的主要仓库指向github上的子模块.我在Bitbucket上的主要回购指向bitbucket上的子模块?
[submodule "programs/mgr-nancy-demo"]
path = programs/mgr-nancy-demo
url = git@github.com:wedkarz/mgr-nancy-demo.git
Run Code Online (Sandbox Code Playgroud) 我有一些共享代码,我想在众多解决方案中分享.大多数示例使用命令行,但我想使用Visual Studio 2013(和/或TortoiseGit)执行此操作?
- SolutionShared
- .git
- Project1Shared
- Project2Shared
- Solution1
- .git
- ProjectFoo
- ProjectBar
- [SolutionShared]
- [Project1Shared]
- [Project2Shared]
- Solution2
- .git
- ProjectBaz
- ProjectQux
- [SolutionShared]
- [Project1Shared]
- [Project2Shared]
Run Code Online (Sandbox Code Playgroud)
我所做的是创建一个新的解决方案SolutionShared,在那里添加我的所有共享代码,并将其添加到自己的git仓库.然后我使用TortoiseGit(因为我无法弄清楚如何做Visual Studio)将该共享repo作为git子模块添加到Solution1和Solution2.
1.我在Visual Studio中做什么?
我的两个解决方案现在有一个SolutionShared目录.我只是在Visual Studio中添加它的两个子项目(Project1Shared和Project2Shared)吗?
2.如何从非共享项目中更改共享代码
如果我在其中一个非共享解决方案中并对子模块中的某些内容进行了更改,我该如何提交并将其推回到共享解决方案的repo(SolutionShared),以便所有引用它的解决方案都可以使用它?
git-submodules ×10
git ×9
bitbucket ×1
git-merge ×1
git-subtree ×1
git-svn ×1
github ×1
merge ×1
python ×1