2

我正在尝试推送到由服务器上的 gitosis 管理的 git 存储库。当我推动时,我收到此错误:

william@utapau:~/lyre$ git push
Enter passphrase for key '/home/william/.ssh/id_dsa': 
Counting objects: 9, done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 705 bytes, done.
Total 5 (delta 4), 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 inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
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'.
To r:lyre
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'r:lyre'

我发现了这个问题:

Git推送错误'[远程拒绝]主->主(当前已签出分支)'

并在那里尝试了答案,但没有运气。远程存储库没有.git文件夹,因为它是用 gitosis 设置的。那里不应该有工作树或签出分支。

存储库文件夹结构如下所示:

william@sirius:/home/git/repositories/lyre.git$ ls -hal
total 40K
drwxr-xr-x   7 git users 4.0K May 24 12:58 .
drwxr-xr-x   5 git users 4.0K May  4  2011 ..
drwxr-xr-x   2 git users 4.0K May  4  2011 branches
-rw-rw-r--   1 git users   66 May 24 12:58 config
-rw-r--r--   1 git users   73 May  4  2011 description
-rw-r--r--   1 git users   23 May  4  2011 HEAD
drwxr-xr-x   2 git users 4.0K May  4  2011 hooks
drwxr-xr-x   2 git users 4.0K May  4  2011 info
drwxr-xr-x 163 git users 4.0K Apr 26 15:26 objects
drwxr-xr-x   4 git users 4.0K May  4  2011 refs

william@sirius:/home/git/repositories/lyre.git$ cd branches/
william@sirius:/home/git/repositories/lyre.git/branches$ ls -hal
total 8.0K
drwxr-xr-x 2 git users 4.0K May  4  2011 .
drwxr-xr-x 7 git users 4.0K May 24 12:58 ..

我怎样才能摆脱这种混乱并推送到存储库?

4

1 回答 1

1

PEBCAK。原来我没有克隆我认为我克隆的存储库。我试图推送到非裸存储库。

在远程服务器上,gitosis 存储库位于/home/git/repositories/lyre.git/,我也有一个克隆位于/home/william/lyre/.

在我的本地工作站上,我~/.ssh/config这样设置:

host r
  user william

当我克隆存储库时,我使用它git clone r:lyre并无意中克隆了克隆而不是 gitosis 存储库。当我尝试推送时,我确实在推送到一个非裸仓库。

我改成~/.ssh/config这样:

host r
  user git

我所有的问题都消失了。这都是一个错误的身份案例。

于 2012-05-25T14:44:10.433 回答