2

因为我创建了一个共享 repo 文件夹,路径为://web1/www 在另一台 PC 中,我创建了一个文件夹,然后打开了 bash,我做了:

$ git clone //web1/www

然后在新创建的 repo 文件夹中:

$ git status
# On branch master
nothing to commit, working directory clean

我添加了一个文件,然后:

$ git add .
$ git commit -m 'new file added'
$ git push origin master

但是,这就是我在下面得到的错误,知道我现在该怎么办吗?

$ git push origen master
fatal: 'origen' 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.

s.ali@WEB2 /d/ketab projects/www (master)
$ git remote -v
origin  //web1/www (fetch)
origin  //web1/www (push)

s.ali@WEB2 /d/ketab projects/www (master)
$ git push origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 257 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsist
ent
remote: error: with what you pushed, and will require 'git reset --hard' to matc
h
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to

remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into

remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some

remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set

remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

PS:我在 Windows 7 本地网络上,使用域而不是工作组

4

2 回答 2

1

这是因为您的来源是一个完整的存储库。

如果你想推送到一个仓库,它需要是一个光秃秃的(没有工作树)

创建 repo 时使用 --bare 标志

git init --bare

push 命令只更新内部 git 文件,而不是工作目录。所以本质上,如果你推送到一个完整的仓库,HEAD(工作目录中的签出文件)实际上将在你刚刚推送的前沿提交的后面。所以 git 开发人员决定不允许这样做。

于 2013-01-08T21:02:55.737 回答
0

git push 起源大师

它的起源

git push origin master
于 2013-01-08T17:20:15.180 回答