简体   繁体   English

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

[英]git push error while push to remote repository

We are new to Git and planning to create local repository in windows and share between team through LAN. 我们是Git的新手,并计划在Windows中创建本地存储库,并通过LAN在团队之间共享。 We have followed following steps and facing issue while push the repository to other. 我们遵循以下步骤并面临问题,同时将存储库推送到其他人。

Created new folder D:/Git/Repository and shared the Git folder to team member using windows file sharing option. 创建新文件夹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)

Added new file (Readme.txt) into the repository location 将新文件(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)

Again initialized repository with –bare option $ git --bare init 再次使用-bare选项初始化存储库$ git --bare init

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

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

Added to remote 添加到远程

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

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

Try to push the changes into other repository, getting some fatal error 尝试将更改推送到其他存储库,获得一些致命错误

$ 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)

You should avoid re-initialize an repo with a working directory (git internal files will be mixed up with your project files) and you should avoid having a working tree in a "remote" repo. 您应该避免使用工作目录重新初始化repo(git内部文件将与您的项目文件混在一起),您应该避免在“远程”仓库中使用工作树。

In this case git fails to find //host/D/Git/Repository on your filesystem. 在这种情况下,git无法在您的文件系统上找到//host/D/Git/Repository

Assuming you already have a project prepared on Github: 假设您已经在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

You should not share this private local repo with other developers. 您不应与其他开发人员共享此私有本地存储库。

If you need a shared repo on the file system (assuming "d:" is a shared disc): 如果您需要在文件系统上使用共享仓库(假设“d:”是共享光盘):

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

Each developer then clone the shared repo into private local repo: 然后,每个开发人员将共享仓库克隆到私有本地仓库中:

$ git clone d:/git/sharedrepo c:/git/myrepo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM