- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有以下 git 结构
- git-repo a
-- subdirectory 2015
--- git-submodule b
-- git-submodule c
--- git-submodule d
我想将 git 子模块 c 移动到文件夹 2015。我知道执行此操作的“肮脏方法”(涉及修改 .git/config 和更改 .git/modules 文件中的几个文件中的 gitdir)
我最近读到 git mv 应该能够做到这一点,即运行
git mv c 2015/
这适用于没有嵌套子模块(在我的例子中是 d)的存储库。但是,当我在我的目录上运行此命令时,出现类似
的错误fatal: Not a git repository: d/../../.git/modules/c/modules/d
fatal: 'git status --porcelain' failed in submodule 2015/c
(注意,这个错误发生在执行上述移动后的 git status 上)
是否有人知道执行此移动的干净方法(即不涉及手动更改 .git/modules 文件中的路径的方法)?
编辑:(6/10/2015)
我目前最好的不涉及修改任何 git 配置文件的解决方案是(首先确保对 d 的所有更改都已提交并推送到某处)
rm c/d -rf
git mv c 2015
cd 2015/c
git submodule update
编辑:(8/10/2015)
侵入性更小的解决方法
git mv c 2015
rm 2015/c/d/.git
cd 2015/c
git submodule update
编辑:(21/9/2018)
从 git 版本 2.19 开始。这已得到修复,git mv
的行为符合预期。
最佳答案
2018 年第二季度更新和 Git 2.18:
用“git mv
”移动本身有子模块的子模块忘记对嵌套的子模块进行必要的调整;
现在代码路径学会了递归到子模块。
参见 commit 6856077 (2018 年 3 月 28 日)作者:Jonathan Tan ( jhowtan
) .
参见 commit da62f78 , commit 0c89fdd , commit 3b8fb39 , commit f793b89 , commit 61aad92 (2018 年 3 月 28 日)作者:Stefan Beller ( stefanbeller
) .
(由 Junio C Hamano -- gitster
-- merge 于 commit 0c7ecb7,2018 年 5 月 8 日)
submodule: fixup nested submodules after moving the submodule
As submodules can have nested submodules themselves, we'd also want to fix the nested submodules when asked to. Add an option to recurse into the nested submodules and connect them as well.
As submodules are identified by their name (which determines their git directory in relation to their superproject's git directory) internally and by their path in the working tree of the superproject, we need to make sure that the mapping of
name <-> path
is kept intact. We can do that in thegit-mv
command by writing out the.gitmodules
file first and then forcing a reload of the submodule config machinery.
2017 年第四季度更新:
最新的 Git 2.14.x/2.15(2017 年第 4 季度)记录了该错误
参见 commit c514167 (2017 年 9 月 15 日)作者 Heiko Voigt ( hvoigt
) .
(由 Junio C Hamano -- gitster
-- merge 于 commit 450b908 ,2017 年 9 月 25 日)
When using
git-mv
with a submodule it will detect that and update the paths for its configurations (.gitmodules
, worktree and gitfile).
This does not work for recursive submodules where a user renames the root submodule.
2015 年原始答案
我刚刚用 git 2.6.0(在 Windows 上)对其进行了测试,移动带有自己嵌套子模块的子模块似乎有问题:
C:\Users\vonc\prog\git\tests\submove>git clone --recursive a a1
Cloning into 'a1'...
done.
Submodule '2015/b' (C:/Users/vonc/prog/git/tests/submove/b) registered for path '2015/b'
Submodule 'c' (C:/Users/vonc/prog/git/tests/submove/c) registered for path 'c'
Cloning into '2015/b'...
done.
Submodule path '2015/b': checked out 'dc18955ec7b9ad0c04245968e2474646e4d593b2'
Cloning into 'c'...
done.
Submodule path 'c': checked out 'fb4722eaca17ac171b7a2c8c5a1ac1e697f0ee85'
Submodule 'd' (C:/Users/vonc/prog/git/tests/submove/d) registered for path 'd'
Cloning into 'd'...
done.
Submodule path 'c/d': checked out '73cd7b8ff82519720b2fcca18df5ed00dd618b71'
我有:
a1
c
d
2015
b
如果我尝试移动子模块 c
在 2015 子文件夹中:
C:\Users\vonc\prog\git\tests\submove\a1>git mv c 2015/c
C:\Users\vonc\prog\git\tests\submove\a1>git status
fatal: Not a git repository: d/../../.git/modules/c/modules/d
fatal: 'git status --porcelain' failed in submodule 2015/c
我发现我需要修改嵌套模块中的 2 个东西 d
:
1/手动修改.git/modules/c/modules/d/config
注入(inject)正确的路径:
git config -f .git/modules/c/modules/d/config core.worktree ../../../../../2015/c/d
^^^^
2/修改d
工作树:
git config -f .git/modules/c/modules/d/config core.worktree ../../../../../2015/c/d
从那里,git status
有效,但我喜欢(可以肯定)添加 git submodule sync --recursive
:
C:\Users\vonc\prog\git\tests\submove\a1>git submodule sync --recursive
Synchronizing submodule url for '2015/b'
Synchronizing submodule url for '2015/c'
Synchronizing submodule url for '2015/c/d'
git status
确实显示了预期的结果:
C:\Users\vonc\prog\git\tests\submove\a1>git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: .gitmodules
renamed: c -> 2015/c
我添加并提交更改:
C:\Users\vonc\prog\git\tests\submove\a1>git add .
C:\Users\vonc\prog\git\tests\submove\a1>git commit -m "move sub c in 2015/c"
[master 8289632] move sub c in 2015/c
2 files changed, 1 insertion(+), 1 deletion(-)
rename c => 2015/c (100%)
C:\Users\vonc\prog\git\tests\submove\a1>gl
* 8289632 - (HEAD -> master) move sub c in 2015/c (3 seconds ago) <VonC>
* 7ebb8e0 - (origin/master, origin/HEAD) a with sub c (38 minutes ago) <VonC>
我现在克隆那个 repo 以检查移动是否确实正确注册:
C:\Users\vonc\prog\git\tests\submove>git clone --recursive a1 a2
Cloning into 'a2'...
done.
Submodule '2015/b' (C:/Users/vonc/prog/git/tests/submove/b) registered for path '2015/b'
Submodule 'c' (C:/Users/vonc/prog/git/tests/submove/c) registered for path '2015/c'
Cloning into '2015/b'...
done.
Submodule path '2015/b': checked out 'dc18955ec7b9ad0c04245968e2474646e4d593b2'
Cloning into '2015/c'...
done.
Submodule path '2015/c': checked out 'fb4722eaca17ac171b7a2c8c5a1ac1e697f0ee85'
Submodule 'd' (C:/Users/vonc/prog/git/tests/submove/d) registered for path 'd'
Cloning into 'd'...
done.
Submodule path '2015/c/d': checked out '73cd7b8ff82519720b2fcca18df5ed00dd618b71'
如您所见,c
和 c/d
在预期中 2015/
子文件夹:
C:\Users\vonc\prog\git\tests\submove>cd a2
C:\Users\vonc\prog\git\tests\submove\a2>dir 2015\c
Directory of C:\Users\vonc\prog\git\tests\submove\a2\2015\c
03/10/2015 18:10 <DIR> .
03/10/2015 18:10 <DIR> ..
03/10/2015 18:10 29 .git
03/10/2015 18:10 40 .gitmodules
03/10/2015 18:10 <DIR> d
2 File(s) 69 bytes
3 Dir(s) 23 656 910 848 bytes free
C:\Users\vonc\prog\git\tests\submove\a2>dir 2015\c\d
Directory of C:\Users\vonc\prog\git\tests\submove\a2\2015\c\d
03/10/2015 18:10 <DIR> .
03/10/2015 18:10 <DIR> ..
03/10/2015 18:10 42 .git
03/10/2015 18:10 3 d.txt
2 File(s) 45 bytes
2 Dir(s) 23 656 910 848 bytes free
关于Git:递归移动子模块(嵌套子模块),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32782382/
我最近在我的机器上安装了 cx_Oracle 模块,以便连接到远程 Oracle 数据库服务器。 (我身边没有 Oracle 客户端)。 Python:版本 2.7 x86 Oracle:版本 11.
我想从 python timeit 模块检查打印以下内容需要多少时间,如何打印, import timeit x = [x for x in range(10000)] timeit.timeit("
我盯着 vs 代码编辑器上的 java 脚本编码,当我尝试将外部模块包含到我的项目中时,代码编辑器提出了这样的建议 -->(文件是 CommonJS 模块;它可能会转换为 ES6 模块。 )..有什么
我有一个 Node 应用程序,我想在标准 ES6 模块格式中使用(即 "type": "module" in the package.json ,并始终使用 import 和 export)而不转译为
我正在学习将 BlueprintJS 合并到我的 React 网络应用程序中,并且在加载某些 CSS 模块时遇到了很多麻烦。 我已经安装了 npm install @blueprintjs/core和
我需要重构一堆具有这样的调用的文件 define(['module1','module2','module3' etc...], function(a, b, c etc...) { //bun
我是 Angular 的新手,正在学习各种教程(Codecademy、thinkster.io 等),并且已经看到了声明应用程序容器的两种方法。首先: var app = angular.module
我正在尝试将 OUnit 与 OCaml 一起使用。 单元代码源码(unit.ml)如下: open OUnit let empty_list = [] let list_a = [1;2;3] le
我在 Angular 1.x 应用程序中使用 webpack 和 ES6 模块。在我设置的 webpack.config 中: resolve: { alias: { 'angular':
internal/modules/cjs/loader.js:750 return process.dlopen(module, path.toNamespacedPath(filename));
在本教程中,您将借助示例了解 JavaScript 中的模块。 随着我们的程序变得越来越大,它可能包含许多行代码。您可以使用模块根据功能将代码分隔在单独的文件中,而不是将所有内容都放在一个文件
我想知道是否可以将此代码更改为仅调用 MyModule.RED 而不是 MyModule.COLORS.RED。我尝试将 mod 设置为变量来存储颜色,但似乎不起作用。难道是我方法不对? (funct
我有以下代码。它是一个 JavaScript 模块。 (function() { // Object var Cahootsy; Cahootsy = { hello:
关闭。这个问题是 opinion-based 。它目前不接受答案。 想要改进这个问题?更新问题,以便 editing this post 可以用事实和引文来回答它。 关闭 2 年前。 Improve
从用户的角度来看,一个模块能够通过 require 加载并返回一个 table,模块导出的接口都被定义在此 table 中(此 table 被作为一个 namespace)。所有的标准库都是模块。标
Ruby的模块非常类似类,除了: 模块不可以有实体 模块不可以有子类 模块由module...end定义. 实际上...模块的'模块类'是'类的类'这个类的父类.搞懂了吗?不懂?让我们继续看
我有一个脚本,它从 CLI 获取 3 个输入变量并将其分别插入到 3 个变量: GetOptions("old_path=s" => \$old_path, "var=s" =
我有一个简单的 python 包,其目录结构如下: wibble | |-----foo | |----ping.py | |-----bar | |----pong.py 简单的
这种语法会非常有用——这不起作用有什么原因吗?谢谢! module Foo = { let bar: string = "bar" }; let bar = Foo.bar; /* works *
我想运行一个命令: - name: install pip shell: "python {"changed": true, "cmd": "python <(curl https://boot
我是一名优秀的程序员,十分优秀!