git推送失败:`拒绝更新签出的分支:refs/heads/master`

2024-05-03

我想将我对 JBoss 配置的本地修改存储在 git 中。为此,我设置了以下结构:

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 发行版。我想将对分布式 JBoss 包的所有本地修改存储在 git 中。

所以,目前我这样做:

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

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

但是,一旦我进行了本地修改并希望将它们恢复到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 "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/'

对此我能做什么?任何帮助是极大的赞赏!

EDIT

这就是我所做的,它解决了这个问题:

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

现在,分行current在目录中~/local始终是最新的,但尚未签出,以便我可以推送它。


推送适用于裸存储库。对于非裸存储库,您应该将其拉入其中。

如果您想强制执行此操作,可以按照错误消息的说明进行操作,并将 receive.denyCurrentBranch 设置为忽略。通过 SSH 连接到您要推送到的存储库位置并运行:

git config receive.denyCurrentBranch ignore
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

git推送失败:`拒绝更新签出的分支:refs/heads/master` 的相关文章

随机推荐

  • git merge 中“递归合并模式”旁边的这些符号是什么?

    当我使用git pull project name master为了更新我的核心文件 我在 递归合并 下得到了一堆绿色的加号和红色的减号信号 这些符号是什么以及它们的含义是什么 这是一个屏幕截图 感谢您的帮助 这是已更改的行数的近似值 优点
  • 使用C#在SQL Server上执行sql文件

    我有很多程序 视图 函数等文件 我想在 SQL Server 2005 2008 上的适当数据库中执行这些文件 创建组件 还有一点是我想使用 C 来执行它们 另一点需要提及的是 我希望应用程序也可以在远程 SQL Server 上执行此文件
  • 如何编写用于退出 JavaScript 的 Typescript 定义文件

    我想使用 React 组件https github com alexkuz react json tree https github com alexkuz react json tree这是在我的 typescript 项目中用 Java
  • SocketTimeoutException:插入 Google 云端硬盘时读取超时 - 是否可以重试?

    如同Java Google Drive SDK File insert execute 上的 SocketTimeoutException https stackoverflow com questions 17583630 java go
  • 如何在Windows上启动JBoss AS 7.1.1?

    我是新来的JBOSS 我下载了jboss as 7 1 1 Final zip并解压缩该 zip 文件 然后我转到 bin 文件夹并双击standalone bat 但新的 cmd 窗口在 2 3 秒内打开和关闭 我尝试通过cmd启动服务器
  • 无法在 JDBCPreparedStatement 中使用 LIKE 查询吗?

    查询代码及查询方式 ps conn prepareStatement select instance id from eam measurement where resource id in select RESOURCE ID from
  • 解释为什么没有船的空 scenekit 场景只有一个节点和 2.73K 多边形

    为什么移除船舶后的空 scenekit 场景只有一个节点和 2 73K 多边形数 如果我展开统计视图 会看到两个节点和 5 46K 个多边形 它必须与统计视图有关 但为什么有这么多多边形 为什么这个视图会出现在场景内部 一个空的 Scene
  • 如何在特定时间启动Tornado周期性回调?

    目前在我的 Tornado 应用程序中 我正在使用定期调用回调PeriodicCallback每隔一小时 像这样 import tornado ioloop from tornado ioloop import PeriodicCallba
  • 将视图控制器推送到 UINavigationController 中

    我有一个带有导航控制器的选项卡视图控制器 在第一个选项卡项中 我单击视图中的按钮 弹出一个带有动画的视图 是 然后 当该视图完成后 我点击另一个按钮将其关闭 喜欢 self dismissViewControllerAnimated NO
  • tikz:为节点设置适当的x值

    这个问题源于这个问题here https stackoverflow com questions 2772972 latex curly braces outside math 我想生成一个跨越一些文本行的大括号 问题是我必须手动对齐 x
  • 如何将 typedef 结构传递给函数?

    此刻我正在努力 void avg everything 但这给了我错误 error subscripted value is neither array nor pointer 当我今天早些时候收到此错误时 这是 因为我没有正确地将 2D
  • 使用 PuLP 进行线性优化,变量附加条件

    我必须用 Pull 解决 Python 中的整数线性优化问题 我解决了基本问题 现在我必须添加额外的约束 有人可以帮助我用逻辑指示器添加条件吗 逻辑限制是 如果 A gt 20 则 B gt 5 这是我的代码 from pulp impor
  • 用于从多个目录复制和重命名文件的批处理文件

    我之前曾寻找过我的问题的答案 但到目前为止还没有具体的答案 看 使用xcopy将多个目录中的文件复制到一个目录 https stackoverflow com questions 585091 using xcopy to copy fil
  • OpenMP 动态调度与引导调度

    我正在研究 OpenMP 的调度 特别是不同的类型 我了解每种类型的一般行为 但澄清一下何时进行选择会很有帮助dynamic and guided调度 英特尔的文档 https software intel com en us articl
  • 如何将多个矩形打包为 2d 盒子俄罗斯方块样式

    我有许多不同宽度和高度的矩形 我有一个更大的矩形平台来放置它们 我想将它们包装在平台的一侧 以便它们在纵向 X 尺寸上展开 但将横向 Y 尺寸保持在最小限度 就是把它们像俄罗斯方块游戏一样放置 不能有重叠 但可以有间隙 有没有算法可以做到这
  • C++ 头文件包含

    我正在开发一个项目 每个头文件都有一个预处理器包含防护 我的包含是这样的 文件 gt 包含 main cpp gt header h 字符 h header h gt 矢量 iostream DataFiles h Character h
  • Dojo 是否可以与其他 JS 框架结合?

    我们使用 Dojo 1 9 3 作为构建单页面应用程序的 JS 框架 然而 我们在 Dojo 的怪癖上花费了太多时间 因此即使是简单的任务也需要很长时间才能实现 由于缺乏适当的文档 我们经常不得不求助于阅读源代码 然后实施解决方法 我觉得如
  • 在 Monogame 和 UIKit 之间切换

    我一直在搜索和搜索 但似乎找不到适合我想做的事情的解决方案 而且我几乎已经到了不得不问它是否可能的地步 我正在使用 Xamarin Studio 开发 iOS 应用程序 我有几个不同的屏幕设置为 UIViewController 它们运行良
  • Python中如何实现相对导入

    考虑 stuff init py mylib py Foo init py main py foo init py script py script py想要进口mylib py 这只是一个示例 但实际上我只想在父目录中进行模块的相对导入
  • git推送失败:`拒绝更新签出的分支:refs/heads/master`

    我想将我对 JBoss 配置的本地修改存储在 git 中 为此 我设置了以下结构 lrwxrwxrwx 1 jboss jboss 19 Jan 24 11 53 current gt jboss as 7 1 0 CR1b drwxr x