获取“receive.denyCurrentBranch”推送到裸 Git 存储库时出错
有一个远程 git bare 存储库,我将一个分支从一台机器推送到该存储库上,然后拉到另一台机器上。
在另一台计算机上进行了一些更改,尝试将这些更改推回到远程裸存储库,我收到“receive.denyCurrentBranch”错误。
这是怎么回事?
这不应该发生在裸仓库上 - 没有检查任何内容。
从机器 2 上看到的分支是:
Fix
dev1
dev2
remotes/origin/HEAD -> origin/dev1
remotes/origin/Fix
remotes/origin/dev1
remotes/origin/dev2
remotes/origin/master
“Fix”是两台开发机器上的当前分支。
当我最初在机器 2 上拉出该分支时,我做了:
git pull
git checkout -b Fix origin/Fix
我对第一条“远程”线表示怀疑 - 似乎 HEAD 应该指向我当前的分支,但事实并非如此。我想我在这里遗漏了一些东西..
更新 1 我将“Fix”分支合并到 dev1 分支,然后推送“dev1”分支 - 工作正常(无论如何,我正要这样做)。
所以,这是一个解决方法,但我认为真正的问题是 HEAD 没有绑定到当前分支(“Fix”),而是绑定到非活动分支(“dev1”)。我不确定如何更改远程仓库上的头?
Have a remote git bare repo that onto which I've pushed a branch from one machine, and pulled to another machine.
Made some changes on the other machine, trying to push those changes back to the remote bare repo, and I get the 'receive.denyCurrentBranch' error.
What's going on?
This isn't supposed to happen on a bare repo - there's nothing checked out on it.
The branches as seen from machine 2 are:
Fix
dev1
dev2
remotes/origin/HEAD -> origin/dev1
remotes/origin/Fix
remotes/origin/dev1
remotes/origin/dev2
remotes/origin/master
'Fix' is the current branch on both dev machines.
When I originally pulled that branch on machine 2, I did:
git pull
git checkout -b Fix origin/Fix
I'm suspicious of the first 'remotes' line - seems that the HEAD should be pointing to my current branch, but it isn't. Think I'm missing something, here..
Update 1
I merged the 'Fix' branch down to the dev1 branch, and then pushd the 'dev1' branch - that worked ok (I was about to do that, anyway).
So, that was a workaround, but I think the real problem was that the HEAD wasn't tied to the current branch ('Fix'), but to an inactive branch ('dev1'). I'm not sure how to change the head on the remote repo?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在机器 2 中,要将引用从本地存储库上传到远程存储库,您可以在推送命令中使用显式引用:
之后,在机器 1 中,您应该使用 fetch 命令获取远程引用
在分支列表中 (git branch -a),你会找到origin/Fix(或remotes/origin/Fix),你可以使用checkout命令直接浏览远程分支的内容:
进行更改、提交等...然后推送它使用机器 2 中使用的相同命令:
要跟踪分支(即创建一个“指向”远程分支的本地分支,请使用带有 --track 的 checkout 命令> 选项):
然后,您可以在本地分支修复上进行修复并进行推送和拉取,而无需其他参数
From the Machine 2, to upload refs from local repository to remote repository you can use explicit refs in the push command:
After that, in the Machine 1, you should use the fetch command to obtain the remote refs
In the list of branches (git branch -a), you will found origin/Fix (or remotes/origin/Fix), you can browser the content of the remote branch directly by using the checkout command:
Make your changes, commit, etc... and then push it using the same command used in machine 2:
To track the branch (this is, create a local branch that "points" the remote branch, use the checkout command with --track option):
Then, you can work on local branch Fix and do push and pull without other arguments