获取“receive.denyCurrentBranch”推送到裸 Git 存储库时出错

发布于 2024-09-29 11:00:21 字数 731 浏览 5 评论 0原文

有一个远程 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奢欲 2024-10-06 11:00:21

在机器 2 中,要将引用从本地存储库上传到远程存储库,您可以在推送命令中使用显式引用:

git push origin Fix:refs/heads/Fix

之后,在机器 1 中,您应该使用 fetch 命令获取远程引用

git fetch

在分支列表中 (git branch -a),你会找到origin/Fix(或remotes/origin/Fix),你可以使用checkout命令直接浏览远程分支的内容:

git checkout origin/Fix

进行更改、提交等...然后推送它使用机器 2 中使用的相同命令:

git push origin Fix:refs/heads/Fix

要跟踪分支(即创建一个“指向”远程分支的本地分支,请使用带有 --track 的 checkout 命令> 选项):

git checkout --track -b Fix origin/Fix

然后,您可以在本地分支修复上进行修复并进行推送和拉取,而无需其他参数

git pull
git commit
git push

From the Machine 2, to upload refs from local repository to remote repository you can use explicit refs in the push command:

git push origin Fix:refs/heads/Fix

After that, in the Machine 1, you should use the fetch command to obtain the remote refs

git fetch

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:

git checkout origin/Fix

Make your changes, commit, etc... and then push it using the same command used in machine 2:

git push origin Fix:refs/heads/Fix

To track the branch (this is, create a local branch that "points" the remote branch, use the checkout command with --track option):

git checkout --track -b Fix origin/Fix

Then, you can work on local branch Fix and do push and pull without other arguments

git pull
git commit
git push
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文