我使用 "git init" 创建了一个git仓库。一切都运行良好,但当我从主机上执行 "git push" 时,它不能推送文件,而是出现以下错误。
使用 "git init --bare" 命令时,不会像"git init" 命令一样创建 ".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 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 root@10.111.44.77:/var/cache/git/h.git
! [remote rejected] master -> master (branch is currently checked out)
当我使用git clone --bare old.git new.git
将旧的.git仓库克隆到新的.git仓库并将文件推送到新的.git仓库时,一切正常。
但是当我使用git init --bare
创建一个新的裸仓库时,它不允许使用"git add"命令。它会给出以下错误:
fatal: This operation must be run in a work tree
使用 "git init --bare" 命令时,不会像"git init" 命令一样创建 ".git" 文件夹。
感谢您的阅读。