【发布时间】:2018-12-17 08:28:17
【问题描述】:
我正在尝试创建一个本地 git 服务器,然后我将克隆它并在我的同一台机器上使用它。
我阅读了这个 stackoverflow 答案:
How to add a local repo and treat it as a remote repo
如果您的目标是保留存储库的本地副本以便于备份 或用于粘贴到外部驱动器或通过云存储共享 (Dropbox 等)您可能想要使用裸存储库。这让你 创建没有工作目录的存储库副本, 优化分享。
$ git init --bare ~/repos/myproject.git $ cd /path/to/existing/repo $ git remote add origin ~/repos/myproject.git $ git push origin master
所以我在我的 D 盘中继续前进并完成了以下操作:
- 创建了一个带有 .git 扩展名的
gitserver.git folder,它是一个文件夹。 - 在我右键单击该文件夹并选择 gitbash 后运行
$ git init --bare - 在根 D 驱动器中创建了另一个名为 gitclient 的文件夹。
- 在 gitclient 中右键单击并选择 gitbash 并尝试运行
git remote add origin D:/gitserver.git
我得到的没有工作
$ git remote add origin D:/gitserver.git
fatal: not a git repository (or any of the parent directories): .git
这可能与路径有关。
如果有人发布答案,请描述如何在 gitbash 中使用 windows 路径,每个人都认为 linux 是处理 git 时唯一的操作系统。
【问题讨论】:
-
在处理 git 时,每个人都认为 linux 是唯一的操作系统,仅供参考,GIT 是由 Linus Torvalds 设计的,用于管理 Linux 内核源代码。甚至是named after him。所以它是为在 Linux 上使用而设计的。 Windows 开发人员刚刚赶上了这股潮流,因为它比其他任何东西都要好得多 (SVN)
-
您只创建了
gitclient文件夹,但没有创建git init。