1和1 git服务的拉式工作、推式不工作

1和1 git服务的拉式工作、推式不工作,git,Git,我正在为他们提供的GIT使用1und1.de服务。现在我正在设置它,并使用git pull命令将更改从那里拉到本地计算机ssh://......... 但是当我试着去推git的时候ssh://...... 我收到了很多错误: remote: error: refusing to update checked out branch: refs/heads/master remote: error: by default, updating the current branch in a non-b

我正在为他们提供的GIT使用1und1.de服务。现在我正在设置它,并使用git pull命令将更改从那里拉到本地计算机ssh://.........

但是当我试着去推git的时候ssh://...... 我收到了很多错误:

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 incosistent

Auto packing the repository for optimum performance.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 arranged to update its work tree to match waht you pushed in some other way.

remote: error: to sqelch this message and still keep the default behaviour, set
remote: error: receive.denyCurrentBranch' configuration variable to 'refuse'.
! [remote_rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://........' 

设置要推送到的存储库时,请将其设置为
bare
存储库:

git init --bare
虽然从技术上讲,通过工作目录推送回购协议是可能的,但这太令人头痛了,在这种情况下,您甚至不希望这样


只需将repo重新创建为裸repo或从中创建裸repo(
git clone--bare/path/to/repo

有两种类型的git存储库。裸存储库通常称为
foo.git
,没有工作树,只有git的内部文件。非裸存储库是一个工作树(即包含所有文件的目录),其中还包含一个名为
.git
的目录。正如错误消息所解释的,推入非裸存储库通常是个坏主意,因为当您这样做时,工作树相对于存储库就过时了

当您托管一个存储库供人们从中提取和推入时,您几乎总是想要一个空的存储库。在本例中,您似乎创建了一个非裸存储库。由于您没有提供关于如何创建存储库的任何详细信息,因此我无法告诉您做错了什么,但您可以通过以下两种方式之一创建一个裸存储库:

  • 从要创建存储库的目录中,发出
    git clone--bare path/to/original.git
    。这将把源代码克隆到您所在目录中的裸存储库
    original.git
  • 从要创建存储库的目录中,发出
    git init--bare foo.git
    。这将在您所在的目录中创建一个空的裸存储库
    foo.git

  • 你可以做更多的事情,但最容易做到。在现有存储库中发出
    git config--set core.bare false
    将使git认为从那时起它是一个裸存储库,但是您必须自己删除工作树,并且您可能应该将存储库从
    .git
    重命名为
    foo.git

    您是如何设置该存储库的?他们是为你做的吗?不,是的,我只是输入了:git init命令,你认为我应该做一些像git init--bare。。或者我需要将其配置为接受git push?我希望现有的git remote更改为bare repo,但我担心我可能会做错什么,并更改我数据库中的文件server@TooCooL-将repo克隆到不同的位置,如so
    git Clone--bare/path/to/repo
    。看看它是否有效。然后替换旧文件是否可以删除服务器中的.git文件删除此git repo中的所有内容,然后运行命令git init--bare并将文件添加到git tracking,我不关心提交,因为我没有提交,当我启动它时只有一个。我希望现有的git remote更改为bare repo,但我担心我可能会做错什么,并更改我服务器中的文件如果您的本地副本是最新的,只需删除服务器上的工作树并重新启动。通过删除.git文件删除工作树?通过删除包含
    .git
    目录的目录删除工作树:即,包含所有文件的目录。谢谢,我现在要删除它,并启动一个新的git--bare repo