Git推送错误'[remote rejected] master - >主人(分支目前已结帐)' [英] Git push error '[remote rejected] master -> master (branch is currently checked out)'

查看:5381
本文介绍了Git推送错误'[remote rejected] master - >主人(分支目前已结帐)'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天,我发布了一个关于如何克隆 Git 存储库的问题我的一台机器到另一台机器, 如何可以我从另一台机器上'git clone'?



现在我可以成功地从我的资源克隆一个Git仓库(192.168.1.2 )到我的目的地(192.168.1.1)。

但是当我编辑一个文件时,一个 git commit -a -mtest 和一个 git push ,我在我的目的地(192.168.1.1)得到这个错误:

  git push 
hap@192.168.1.2的密码:
计数对象:21,完成。
压缩对象:100%(11/11),完成。
写入对象:100%(11/11),1010字节,完成。
合计11(增量9),重用0(增量0)
错误:拒绝更新检出分支:refs / heads / master
错误:默认情况下,更新当前分支非裸仓库
错误:被拒绝,因为它会使索引和工作树不一致
错误:与你推送的内容相同,并且需要'git reset --hard'以匹配
错误:工作树到HEAD。
错误:
错误:您可以将'receive.denyCurrentBranch'配置变量设置为
错误:'ignore'或'warn'在远程存储库中允许推入
错误:其目前的分支;然而,除非你有
错误,否则不建议这样做:安排更新它的工作树来匹配你在某些
错误中推送的内容:其他方式。
错误:
错误:要压制此消息并仍保持默认行为,请将
错误:'receive.denyCurrentBranch'配置变量设置为'拒绝'。
到git + ssh://hap@192.168.1.2/media/LINUXDATA/working
! [remote rejected] master - > master(分支目前被检出)
错误:未能将一些文件推送到'git + ssh://hap@192.168.1.2/media/LINUXDATA/working'

我使用两个不同版本的Git(远程版本为1.7,本地版本为1.5)。这是一个可能的原因吗?您可以简单地将您的远程仓库转换为裸仓库(仓库中没有工作副本



在远程资料库文件夹中执行以下命令: pre> git config --bool core.bare true

然后删除该文件夹中除 .git 之外的所有文件。然后,您将可以毫无错误地执行 git push 到远程存储库。


Yesterday, I posted a question on how to clone a Git repository from one of my machines to another, How can I 'git clone' from another machine?.

I am now able to successfully clone a Git repository from my source (192.168.1.2) to my destination (192.168.1.1).

But when I did an edit to a file, a git commit -a -m "test" and a git push, I get this error on my destination (192.168.1.1):

git push                                                
hap@192.168.1.2's password: 
Counting objects: 21, done.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 1010 bytes, done.
Total 11 (delta 9), reused 0 (delta 0)
error: refusing to update checked out branch: refs/heads/master
error: By default, updating the current branch in a non-bare repository
error: is denied, because it will make the index and work tree inconsistent
error: with what you pushed, and will require 'git reset --hard' to match
error: the work tree to HEAD.
error: 
error: You can set 'receive.denyCurrentBranch' configuration variable to
error: 'ignore' or 'warn' in the remote repository to allow pushing into
error: its current branch; however, this is not recommended unless you
error: arranged to update its work tree to match what you pushed in some
error: other way.
error: 
error: To squelch this message and still keep the default behaviour, set
error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To git+ssh://hap@192.168.1.2/media/LINUXDATA/working
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'git+ssh://hap@192.168.1.2/media/LINUXDATA/working'

I'm using two different versions of Git (1.7 on the remote and 1.5 on the local machine). Is that a possible reason?

解决方案

You can simply convert your remote repository to bare repository (there is no working copy in the bare repository - the folder contains only the actual repository data).

Execute the following command in your remote repository folder:

git config --bool core.bare true

Then delete all the files except .git in that folder. And then you will be able to perform git push to the remote repository without any errors.

这篇关于Git推送错误'[remote rejected] master - >主人(分支目前已结帐)'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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