Git推入大师失败 [英] Git pushing into master failed...

查看:93
本文介绍了Git推入大师失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定从哪里搜索,因为错误列表与底部一样长.但这通常就是我所做的.

I am not sure where to search from as the error list is as long as the bottom. But generally this is what I did.

我做了什么:

git clone url .
git add abc.txt
git commit -m "testing"
git push origin master / 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'.
To ../git_abc/

推荐答案

您要将master从克隆推送到原始存储库,其中原始存储库本身已签出master,而原始存储库不是bare回购. GIT不允许.

You are pushing master from your clone to the origin repo, where the origin repo itself has master checked out, and the origin repo is not a bare repo. GIT doesn't allow that.

要实现您想做的事情,

git clone  --bare <origin/repo> intermediate

在原始本地存储库上

git remote add upstream <path/to/intermediate>
git push upstream master

在您的原始存储库上

git remote add downstream <path/to/intermediate>
git pull downstream master    

或推送到原始存储库中的其他分支,然后将该分支合并到原始存储库中的master分支中.

来自本地仓库

Or push to some other branch on the origin repo, and merge that branch into the master branch in the origin repo.

From local repo

git push origin master:master_to_be_merged

关于原始存储库

git checkout master
git merge master_to_be_merged

或者忽略这些警告并继续推送

在这种情况下,您将必须格外小心,不要破坏任何东西,而且还是不建议这样做.

Or ignore these warnings and push anyway

In this case, you will have to take extra care that nothing is breaking, and this is anyway not recommended.

在原始存储库上,运行

git config receive.denyCurrentBranch ignore

现在从您的本地克隆中执行

And now from your local clone, do

git push origin master

这篇关于Git推入大师失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆