2015-06-03 35 views

回答

2

您應該提供一個空目錄或在os目錄內運行克隆命令git clone https://github.com/libgit2/libgit2,但git將爲libgit2 repo創建一個具有相同名稱的新目錄。 我想你想添加一個submodulegit submodule add https://github.com/libgit2/libgit2

+1

您對子模塊的引用是關鍵。只要這是OP所需要的,他狀態良好。不好的是,如果他想使用回購站的文件和其他不受管理的文件進行操作。這不是一個好主意。 – GreenAsJade

+0

我同意你不能在同一個目錄中混合來自不同repo的文件。這是一個不好的方法,因爲目標是獨立管理每個回購 – Raulucco

1

如一般Git是非常小心,從來無意破壞文件我的感覺告訴我,這是不可能的,也不會是一個好主意。但讓我們嘗試:

$ mkdir p1 
$ echo 'hi' > p1/foo.txt 
$ cd p1/ 
$ git init 
Initialized empty Git repository in /Users/joern/coding/git/tmp/p1/.git/ 
$ git add foo.txt 
$ git commit -m'init' 
[master (root-commit) ad640a7] init 
1 file changed, 1 insertion(+) 
create mode 100644 foo.txt 
$ cd .. 
$ mkdir p2 
$ echo 'hallo' > p2/bar.txt 
$ git clone p1 p2 
fatal: destination path 'p2' already exists and is not an empty directory. 

因此,毫無疑問,這是行不通的。如果您當前的os是git目錄,那麼您可能在Raulucco's answer之後。如果您只是想將os文件提交到上游存儲庫,建議將您的lib克隆到新目錄中,然後將舊文件夾中的所有文件複製到其上。這樣,在克隆的文件在混帳回購協議,如果他們出錯,你可以撤消的事情:

$ mv os os.bak 
$ git clone https://github.com/libgit2/libgit2 os 
$ rsync -avPi os.bak/ os/ 
$ # review the os directory before finally doing 
$ rm -r os.bak 
1

對於您所提供的語法,應該是一個空目錄。我使用了一個「dao」存儲庫,用於舉例說明:

D:\sites-personal 
λ mkdir dao 

D:\sites-personal 
λ cd dao\ 

D:\sites-personal\dao 
λ touch file.txt 

D:\sites-personal\dao 
λ cd .. 

D:\sites-personal 
λ git clone [email protected]/dao.git dao 
fatal: destination path 'dao' already exists and is not an empty directory. 
相關問題