GIT 1.9 - 远程 : error: 'receive.denyCurrentBranch'

标签 git github version-control

我在使用 Git 1.9 时遇到错误。
当我尝试“git push”时,我收到以下错误:

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'.

所以,我的第一步是在这个论坛上阅读大量内容,并尝试从谷歌中找到一些结果。遗憾的是,我发现的所有内容都不适用于我的情况。

我在 Linux x86 上工作并安装了 Git 1.9。
我可以从我的服务器“git clone”一个存储库并在其中工作。
例如,我在其中“touch testfile”来创建一个新文件。现在我将“git commit”这个文件。
在这一步之后,我“git push”它,然后我得到了错误代码。

我在其他文章中发现问题在git 2.3中得到解决 并且从存储库的配置文件中更改“receive.denyCurrentBranch”的值应该会有所帮助。 有用的值应该是:refuseupdateInsteadignore

我都试过了,错误总是一样。

在服务器上配置值是:

[receive]
        denyCurrentBranch = refuse

和“git 分支

*master

在客户端,“git status”是:

On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

所以,这个错误随时都会出现,我还不知道怎么解决。
如何避免该错误消息?

最佳答案

一般的最佳做法是在您的服务器上创建一个 bare repo (git init --bare,或 convert your existing repo to a bare one ),克隆它,添加并提交新文件,然后推送。
该推送不会有您描述的错误消息。

请注意,Git 1.9 中不存在允许推送到非裸仓库的任何功能(2.3 receive.denyCurrentBranch updateInstead2.4 push-to-deploy)。
您应该能够安装 latest Git 2.13 from the right ppa .

关于GIT 1.9 - 远程 : error: 'receive.denyCurrentBranch' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44406360/

相关文章:

java - Maven:传递-循环依赖-发布流程

git - 提交没有出现在 github 上

github - GitHub 上的 FontAwesome 风格的 Markdown

version-control - 让 vc-diff 在 Emacs 23.2 中使用 ediff

git - 通过 web 界面在 Gitlab repo 中创建一个目录

svn - 删除了一个添加到 TortoiseSVN 但未提交的文件

git - 为什么 `git show` 不提供有关重定向标准输出的分支信息?

git - 如果两个分支的最终快照相同但提交路径不同,它们是否相同?

python - 无法使用 python 自动执行 git fetch && git checkout

iOS Github操作(构建,测试和部署)