为什么我不能推新克隆的回购?

时间:2013-01-08 14:42:17

标签: git

我创建了一个共享的repo文件夹,其中包含path:// 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'.

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

2 个答案:

答案 0 :(得分:1)

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

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

创建回购时使用--bare标志

git init --bare

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

答案 1 :(得分:0)

  

git push origen master

它的起源

git push origin master