如何使用.git提交并推送子文件夹到github?

时间:2014-08-06 05:20:18

标签: git github hexo

我的博客是使用hexo构建的,将在blog

中推送到github个回购

博客/

- 主题/

----吃豆/

但是有一个子订单pacman。它是从github中的其他repo克隆的,这意味着它有自己的.git文件夹。

当我尝试提交并将整个目录推送到blog repo时,pacman的内容不会被推送到github

我尝试删除.git中的pacman,但也无法将其推送到github

删除.git

中的pacman后,这是git状态
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean

以下是.gitignore,就我所见,它与pacman无关

.DS_Store
Thumbs.db
db.json
debug.log
node_modules/
public/
.deploy/

当我推送到blog回购时,我想将所有内容都推到pacman下面。我怎么能这样做?

1 个答案:

答案 0 :(得分:3)

看起来你有子模块(hexo-theme和pacman),但没有.gitmodules文件。

以下是删除这些空文件夹的内容:

diff --git a/themes/hexo-theme b/themes/hexo-theme
deleted file mode 160000
index 994a837..0000000
--- a/themes/hexo-theme
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 994a83762b8ef83d7516c098f4ad5065f6886304
diff --git a/themes/pacman b/themes/pacman
deleted file mode 160000
index 8a9440c..0000000
--- a/themes/pacman
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 8a9440ca773dccf8ea30c3fc0cea342e0707b360

它们是外部子模块引用。

你可以从这里做什么,删除那些文件夹,提交更改,然后再次复制(不使用git)(没有.git)。然后,您应该能够将它们添加并存储到您的存储库中。

您还可以坚持使用子模块,这样您就可以更新它们。