如何用代码中的代码替换git子模块?

时间:2011-05-12 06:51:29

标签: git merge git-submodules

我最近一直在摆脱git子模块。有时我会在子模块中添加新文件。

我正在寻找一种删除子模块的好方法,并在其中添加一些文件,而不会为拉动用户造成合并问题。

这就是我所说的:

这是一个提交,我删除了一个子模块定义并添加了一些文件作为替换:

$:~/src/github/huerlisi/mailyt$ git show d1e7e1276fdccb37f775c8f656077e490a0b7be8
commit d1e7e1276fdccb37f775c8f656077e490a0b7be8
Author: Simon Hürlimann (CyT) <simon.huerlimann@cyt.ch>
Date:   Wed May 11 22:07:49 2011 +0200

    Vendor in formtastic sass, drop git submodule.

diff --git a/.gitmodules b/.gitmodules
index 24f8f38..e6177d1 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
 [submodule "vendor/plugins/fetcher"]
        path = vendor/plugins/fetcher
        url = git://github.com/huerlisi/fetcher.git
-[submodule "app/stylesheets/partials/formtastic"]
-       path = app/stylesheets/partials/formtastic
-       url = git://github.com/activestylus/formtastic-sass.git
diff --git a/app/stylesheets/partials/formtastic b/app/stylesheets/partials/formtastic
deleted file mode 160000
index 1b920cb..0000000
--- a/app/stylesheets/partials/formtastic
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 1b920cb2db627cb7cf11cf4d3cea373a774a6fd3
diff --git a/app/stylesheets/partials/formtastic/_formtastic_base.sass b/app/stylesheets/partials/formtastic/_formtastic_base.sass
new file mode 100644
index 0000000..b01ac8e
--- /dev/null
+++ b/app/stylesheets/partials/formtastic/_formtastic_base.sass
@@ -0,0 +1,652 @@
+//
+// FORMTASTIC SASS
+// Flexible styling for formtastic forms

将此提交合并到我的工作目录并检出子模块会出现此错误:

~/src/github/huerlisi/mailyt$ git pull
remote: Counting objects: 35, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 24 (delta 16), reused 0 (delta 0)
Unpacking objects: 100% (24/24), done.
From github.com:huerlisi/mailyt
   2d055d6..82a45be  master     -> origin/master
 * [new branch]      notmuch    -> origin/notmuch
Updating 2d055d6..82a45be
error: The following untracked working tree files would be overwritten by merge:
        app/stylesheets/partials/formtastic/_formtastic_base.sass
Please move or remove them before you can merge.
Aborting

在合并作品之前手动删除app / stylesheets / partials / formtastic目录。但我希望我的同伴能够简单地拉动和编码。

1 个答案:

答案 0 :(得分:2)

你无法为他们做任何事。由于子模块是具有ref log和rerere历史的完整存储库,因此拉不会消除它们。合并也不会。当他们获得这些更改时,他们必须明确地对他们执行rm -rf。这是为了避免人们无意中擦除他们的工作和/或参考日志等。

希望这有帮助