推送到远程存储库时git push错误

时间:2015-08-24 09:48:01

标签: git github version-control

我们是Git的新手,并计划在Windows中创建本地存储库,并通过LAN在团队之间共享。我们遵循以下步骤并面临问题,同时将存储库推送到其他人。

创建新文件夹D:/ Git / Repository,并使用Windows文件共享选项将Git文件夹共享给团队成员。

$ cd d:/Git/Repository

$ git init

Initialized empty Git repository in d:/git/Repository/.git/

user@host /d/git/Repository (master)

将新文件(Readme.txt)添加到存储库位置

$ git add Readme.txt

user@host /d/git/Repository (master)

$ git commit -a -m 'Added Readme'

[master (root-commit) f072a76] Added Readme
 1 file changed, 14 insertions(+)
create mode 100644 Readme.txt
user@host /d/git/Repository (master)

再次使用-bare选项初始化存储库     $ git --bare init

Initialized empty Git repository in d:/git/Repository/

user@host /d/git/Repository (master)

添加到远程

$ git remote add origin file:////host/D/Git/Repository

user@host /d/git/Repository (master)

尝试将更改推送到其他存储库,获得一些致命错误

$ git push origin master

fatal: '//host/D/Git/Repository' does not appear to be a git repository

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

user@host /d/git/Repository (master)

1 个答案:

答案 0 :(得分:0)

您应该避免使用工作目录重新初始化repo(git内部文件将与您的项目文件混淆)并且您应该避免在“远程”仓库中使用工作树。

在这种情况下,git无法在您的文件系统上找到//host/D/Git/Repository

假设您已经在Github上准备了一个项目:

$ git clone <url to project on Github> c:/Git/Repository
$ git add Readme.txt
$ git commit -a -m 'Added Readme'
$ git fetch origin
$ git push origin master

您不应与其他开发者共享此私有本地存储库。

如果您需要文件系统上的共享仓库(假设“d:”是共享光盘):

$ cd d:/git/sharedrepo
$ git init --bare --shared

然后每个开发人员将共享仓库克隆到私有本地仓库:

$ git clone d:/git/sharedrepo c:/git/myrepo
相关问题