簡體   English   中英

Git“與工作樹分離的存儲庫”解決方案在Windows下不起作用

[英]Git “repository separate from work tree” solution not working under Windows

看到我鏈接到這個問題的答案:

https://stackoverflow.com/a/8603156/1445967

在最新的Windows Git下,我根本無法正常工作。 (Windows 7 x64)

我用git bash:

<my username> /d/<worktree>
$ git --git-dir=/c/dev/gitrepo/repo.git --work-tree=. init && echo "gitdir: /c/dev/gitrepo/repo.git" > .git
Initialized empty Git repository in c:/dev/gitrepo/repo.git/

然后我嘗試了:

<my username> /d/<worktree>
$ git status
fatal: Not a git repository: /c/dev/gitrepo/repo.git

因此,由於Windows路徑的存儲方式,我嘗試了一些不同的方法...

<my username> /d/<worktree>
$ git --git-dir=/c/dev/gitrepo/repo.git --work-tree=/d/<worktree> init && echo "gitdir: /c/dev/gitrepo/repo.git" > .git
Initialized empty Git repository in c:/dev/gitrepo/repo.git/

這是逐字復制粘貼,只是我將用戶名和單個目錄名稱更改為<worktree>

然后我嘗試了以下方法:

<my username> /d/<worktree>
$ git status
fatal: Not a git repository: /c/dev/gitrepo/repo.git

然后我查看了/c/dev/gitrepo/repo.git/config的內容,然后看到了:

worktree = d:/<worktree>

也許這不適用於Windows路徑符號。 所以我改變了它:

worktree = /d/<worktree>

仍然沒有運氣。 我想在Windows下的git下做些什么嗎?

我在此問題上取得的唯一進步是發現,在我使用的工作站上,使用SUBST命令創建了驅動器D。也就是說,C和D實際上是同一物理驅動器。

SUBST似乎並沒有完全打破Git。 我在驅動器D上有項目,在驅動器D上有一個完全不同的目錄上的git repo,一切正常。

username@host /d/ProjectName (branch)
$ cat .git
gitdir: d:\gitrepo\ProjectName.git

因此,我最好的答案是一種變通辦法,我建議:在Windows中可能存在問題:

1.  If the repo and working dir are on different drives
2.  If (1) is true and you use SUBST

但是無論哪種情況,解決方法都是以下一項或兩項:

1.  put everything on the same drive letter.  It works even if that drive is a 'subst' drive.
2.  Use the windows "d:\" notation in the .git file

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM