我有一个git repo,它有以下文件夹:
_includes/
_layouts/
_plugins/
_posts/
_site/
_site文件夹添加在.gitignore
文件中。
现在我可以在_site文件夹中使用不同的远程仓库进行推送和拉取的git repo吗?会有冲突吗?
我已经研究过git子模块,但我认为如果上述方法可行,我的情况就会过度。
答案 0 :(得分:16)
我认为它应该有效。对于主仓库,_site
文件夹不存在。所以你里面的东西并不重要。当您cd
进入_site
时,您将进入该独立回购。
答案 1 :(得分:6)
是的 - 我刚尝试过。这是我的命令行会话:
$ 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)