33

我有一个 git repo,其中包含以下文件夹:

 _includes/
 _layouts/
 _plugins/
 _posts/
 _site/

_site 文件夹被添加到.gitignore文件中。

现在我可以在 _site 文件夹中有一个 git repo 并使用不同的远程 repo 进行推送和拉取吗?会不会有冲突?

我研究过 git 子模块,但如果上述方法可行,我认为在我的情况下这将是一种矫枉过正。

4

2 回答 2

22

我认为它应该工作。对于主仓库,_site文件夹不存在。所以你里面有什么并不重要。当你cd进入_site你将在那个独立的回购。

于 2012-04-18T08:16:46.930 回答
11

是的 - 我刚试过。这是我的命令行会话:

$ mkdir temp
$ cd temp
$ git init 
Initialized empty Git repository in /Users/mpdaugherty/temp/.git/
$ git add .
$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
$ echo 'ignore' >> .gitignore
$ git add .
$ git commit -a -m 'first commit'
[master (root-commit) 17d293c] first commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore
$ mkdir ignore
$ git status
# On branch master
nothing to commit (working directory clean)
$ cd ignore
$ git init .
Initialized empty Git repository in /Users/mpdaugherty/temp/ignore/.git/
$ echo 'Some text' > somefile.txt
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   somefile.txt
nothing added to commit but untracked files present (use "git add" to track)
$ git add .
$ git commit -a -m 'initial commit'
[master (root-commit) 107f980] initial commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 somefile.txt
$ cd ..
$ git status
# On branch master
nothing to commit (working directory clean)
于 2012-04-18T08:22:22.807 回答