代码之家  ›  专栏  ›  技术社区  ›  Wayne Werner

Git远程存储库(带文件?)

  •  1
  • Wayne Werner  · 技术社区  · 14 年前

    我有一个远程Web服务器,我可以完全访问它(ssh、git等)。我希望能够编辑我的计算机上的文件并将它们推送到远程服务器。当我使用裸存储库时,它不会更改文件,但当我使用非裸存储库时,它会发出以下消息:

    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 t
    remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
    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 som
    remote: error: other way.
    remote: error: 
    remote: error: To squelch this message and still keep the default behaviour, se
    remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
    

    有没有办法在我的笔记本电脑和远程服务器上同时获得工作副本?

    谢谢

    1 回复  |  直到 14 年前
        1
  •  3
  •   igorw    14 年前

    您可以(在服务器上)设置该选项:

    git config receive.denyCurrentBranch ignore
    

    或者在服务器端使用两个存储库。一个是您推送到的裸存储库。另一个是非裸机存储库,它是裸机repo的“工作副本”克隆。你给了裸回购一个后承诺挂钩 cd 在您的工作副本中执行 git pull .