git推送失败:`拒绝更新签出分支:refs / heads / master` [英] git push fails: `refusing to update checked out branch: refs/heads/master`

查看:10306
本文介绍了git推送失败:`拒绝更新签出分支:refs / heads / master`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在git中将我的本地修改保存到JBoss配置中。为此,我建立了以下结构:

  lrwxrwxrwx 1 jboss jboss 19 Jan 24 11:53 current  - > jboss-as-7.1.0.CR1b 
drwxr-xr-x 11 jboss jboss 4096 Jan 24 12:13 jboss-as-7.1.0.CR1b
-rw-r - r-- 1 jboss jboss 108211143 Jan 23 16:02 jboss-as-7.1.0.CR1b.tar.gz
drwxr-xr-x 6 jboss jboss 4096 Jan 24 11:36 local

local 是git仓库,它应该是原点。这个想法是,我希望能够在更新可用时轻松更新我的JBoss发行版。我想在git中存储对分布式JBoss包的所有本地修改。

因此,目前我这样做:

  jboss @ tpl0:〜/ jboss-as-7.1.0.CR1b $ git init 
/opt/jboss/jboss-as-7.1.0中已初始化的空Git存储库.CR1b / .git /
jboss @ tpl0:〜/ jboss-as-7.1.0.CR1b $ git remote add origin ../local/
jboss @ tpl0:〜/ jboss-as-7.1 .0.CR1b $ git pull origin master
从../local
* branch master - > FETCH_HEAD

到目前为止,我所有的本地修改都在我想要的地方。



但是,一旦我进行了本地修改并想将它们重新安装回 local 存储库,我收到一个错误:

  jboss @ tpl0:〜/ jboss-as-7.1.0.CR1b $ vim standalone / configuration / standalone.xml 
jboss @ tpl0:〜/ jboss-as-7.1.0.CR1b $ git commit -a -m将数据库重命名为project2_core,以区别于其他项目
[master 3e54f34]将数据库重命名为project2_core,以区别于其他项目项目
提交者:jboss< jboss @ tpl0。(none)>
1个文件已更改,1个插入(+),1个删除( - )

jboss @ tpl0:〜/ jboss-as-7.1.0.CR1b $ git push origin master
计数对象:9,完成。
压缩对象:100%(4/4),完成。
写入对象:100%(5/5),447字节,完成。
合计5(增量3),重用0(增量0)
开箱对象:100%(5/5),完成。
remote:error:拒绝更新签出分支:refs / heads / master
remote:error:默认情况下,更新非裸仓库中的当前分支
remote:error:is否则,因为它会使索引和工作树不一致
remote:error:用你推送的内容,并且需要'git reset --hard'来匹配
remote:error:工作树到HEAD 。
remote:error:
remote:error:您可以在远程存储库中设置'receive.denyCurrentBranch'配置变量t
remote:error:'ignore'或'warn',以允许推送int
remote:错误:当前分支;然而,除非您
remote:error:安排它更新其工作树以匹配您在som
remote:error:其他方式中推送的内容,否则不建议这样做。
remote:error:
remote:error:为了压制这个信息并保持默认行为,se
remote:error:'receive.denyCurrentBranch'配置变量为'拒绝'。
到../local/
! [remote rejected] master - > master(分支目前已检出)
错误:未能将某些参考推送到'../local/'

我能做些什么?任何帮助非常感谢!



编辑

以下是我所做的,解决了这个问题:

  cd〜/ current 
git init
vim .gitignore#设置基本.gitignore文件
git add .gitignore
git commit -a -m初始提交
cd〜/ local
git clone〜/ current
git branch -m master current#将master分支重命名为'current'
git branch repo
git checkout repo

现在,目录〜/ / local 中的分支当前始终是最新的,但它不是这样我就可以进入它。

解决方案

在远程站点的主分支被检出。如果您有权访问远程存储库,请检出其他分支,然后从存储库中推送。


I want to store my local modifications to JBoss config in git. For this, I have set up the following structure:

lrwxrwxrwx  1 jboss jboss        19 Jan 24 11:53 current -> jboss-as-7.1.0.CR1b
drwxr-xr-x 11 jboss jboss      4096 Jan 24 12:13 jboss-as-7.1.0.CR1b
-rw-r--r--  1 jboss jboss 108211143 Jan 23 16:02 jboss-as-7.1.0.CR1b.tar.gz
drwxr-xr-x  6 jboss jboss      4096 Jan 24 11:36 local

local is the git repository which shall be the "origin". The idea is that I want to be able to easily update my JBoss distribution once an update is available. I want to store all local modifications to the distributed JBoss package in git.

So, currently I do this:

jboss@tpl0:~/jboss-as-7.1.0.CR1b$ git init
Initialized empty Git repository in /opt/jboss/jboss-as-7.1.0.CR1b/.git/
jboss@tpl0:~/jboss-as-7.1.0.CR1b$ git remote add origin ../local/   
jboss@tpl0:~/jboss-as-7.1.0.CR1b$ git pull origin master 
From ../local
 * branch            master     -> FETCH_HEAD

So far so good, all my local modifications are there where I want them.

However, once I have local modifications and want to bush them back to the local repository, I get an error:

jboss@tpl0:~/jboss-as-7.1.0.CR1b$ vim standalone/configuration/standalone.xml   
jboss@tpl0:~/jboss-as-7.1.0.CR1b$ git commit -a -m "renamed database to project2_core,   to distinguish from other projects"
[master 3e54f34] renamed database to project2_core, to distinguish from other projects
Committer: jboss <jboss@tpl0.(none)>
 1 files changed, 1 insertions(+), 1 deletions(-)

jboss@tpl0:~/jboss-as-7.1.0.CR1b$ git push origin master 
Counting objects: 9, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 447 bytes, done.
Total 5 (delta 3), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
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'.
To ../local/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '../local/'

What can I do about this? Any help is greatly appreciated!

EDIT

Here's what I did, which solved the problem:

cd ~/current
git init
vim .gitignore                   # set up a basic .gitignore file
git add .gitignore
git commit -a -m "initial commit"
cd ~/local
git clone ~/current
git branch -m master current     # rename master branch to 'current'
git branch repo
git checkout repo

Now, the branch current in directory ~/local is always up-to-date, but it's not cheked out, so that i can push into it.

解决方案

The master branch at remote site is checked out. If you have access to remote repository, checkout any other branch and then push from your repository.

这篇关于git推送失败:`拒绝更新签出分支:refs / heads / master`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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