Git“无法将一些引用推送到...”使用自定义 Git 桥

发布于 2024-09-10 10:52:18 字数 3588 浏览 5 评论 0原文

我一直致力于使用 Paramiko 作为 Git 的 SSH 桥来设置 git 服务器。我可以毫无问题地克隆我的存储库,甚至可以推送更改,但是我收到一条恼人的错误消息。

Pushing to git@localhost:/pckprojects/heyworld
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 262 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@localhost:/pckprojects/heyworld
     348dfdc..1c0468e  master -> master
updating local tracking ref 'refs/remotes/origin/master'
error: failed to push some refs to 'git@localhost:/pckprojects/heyworld'

我的 git 的配置如下所示:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = true
    sharedRepository = all
[receive]
    denyNonFastForwards = false
    denyCurrentBranch = false
    denyDeletes = false

奇怪的是“master”实际上确实得到了更新,而且我的存储库中没有其他分支。此外,如果我从磁盘而不是通过 SSH 克隆/推送存储库,我不会看到任何错误。

有人对我为什么看到这个错误有任何想法吗?

谢谢...

编辑:

由于我的问题似乎与我的 SSH 服务器有关,因此主循环如下:

        proc = subprocess.Popen(command, stdin=subprocess.PIPE,
                stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        while True:
            try:
                r_ready, w_ready, x_ready = select.select(
                    [channel, proc.stdout, proc.stderr], [proc.stdin], [])
            except Exception, e:
                print e
                print 'channel: ' + str(channel)
                print 'proc: ' + str(proc)

            if channel in r_ready and channel.recv_ready():
                data = channel.recv(128)
                if len(data) > 0:
                    print 'IN>channel ' + repr(data)
                    proc.stdin.write(data)
                else:
                    pass

            if proc.stdout in r_ready:  
                data = proc.stdout.read(1)
                channel.sendall(data)

            if proc.stderr in r_ready:

                data = proc.stdout.read(1)
                if len(data) > 0:
                    channel.sendall(data)

                else:
                    print "Encountered empty stderr, breaking"
                    break                       

        print 'will close'
        channel.shutdown(2)
        channel.close()

更多信息

我认为查看实际通信可能会有所帮助。这是出现在服务器端的,因为 git 客户端不允许你看到这么多。

git-receive-pack /home/www/data/project/heyworld/

OUT >>
00721ee2436e45c80236878132dc87d9e9fee6a81de5 refs/heads/master\x00 report-status delete-refs side-band-64k ofs-delta\n0000

IN >>
00841ee2436e45c80236878132dc87d9e9fee6a81de5 6054b3358787bafd1d96c0fdfbf016d620ccdf09 refs/heads/master\x00 report-status side-band-64k0000

IN >>
PACK\x00\x00\x00\x02\x00\x00\x00\x03\x96\x0ex\x9c\xa5\x8cM\x0e\xc2 \x14\x06\xf7\x9c\x82\x0b\xd8<(?\x8f\xc4\x18\xf7n\xbc\x02\xc2\x87%\x16\xdb4\xb8\xf0\xf66\xbd\x82\xcb\x99d\xa6o\x80\x846\xd9!)\x1b\x0b\xb1\r1$dO\x05\xa6\xb0\xa3@\x06%D<\xb2\x16k\xdc\xf0\xeeRa/F\x07c\x13\x93\x1e\x1d{V\xa3\xce\x89}\x0e\x08\x05p\x91U\x86\x15\xf1\xd3\xa7e\x93\xf7\xa9\xceu\x95\xb7\xda\x1a\xbe\xf2\xbc\x1e8\xbc\x0e\xbc>[\xac\xf3\x90\x96v\x91J\xfb`X\xb3V\xf2D\x96H\xec\xb6\xd5\xde\xf1\xc7B4,\xe2\x07\xff\x8aF\xba\xaf\x01x\x9c340031Q\xc8H\xaddP\xd8P\xfcmzGg\x8aY\xc4\x8e\xad\xb1<\xca\x1b\xa3\x93\xee\xbd\x05\x00\xa8\xb4\x0c\x9by\xd3\xfe\xa0C\x86fU\x18\xbe\xa5\x86\xac5*\xf7\x11\x89\x8b9$x\x9c\x0b\x8b\x9a\x10\xc6\x92\x9b\x9a\xcf\x05\x00\x0f\xb2\x02\xe6=\x12?\xde\x1f\x9a=v\x0c3c\xf66\xc6\xcc1y\xe4\xb8\xa0

OUT >>
0030\x01000eunpack ok\n009krf/ed/atr0000

CLOSE CONNECTION

I have been working on setting up a git server by using Paramiko to act as an SSH bridge for Git. I am able to clone my repository without issue, and even push changes up, however I get an annoying error message.

Pushing to git@localhost:/pckprojects/heyworld
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 262 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@localhost:/pckprojects/heyworld
     348dfdc..1c0468e  master -> master
updating local tracking ref 'refs/remotes/origin/master'
error: failed to push some refs to 'git@localhost:/pckprojects/heyworld'

My git's config looks like this:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = true
    sharedRepository = all
[receive]
    denyNonFastForwards = false
    denyCurrentBranch = false
    denyDeletes = false

The odd thing is "master" actually does get updated, and I have no other branches in the repository. In addition, if I clone / push the repository from disk rather than via SSH, I don't see any errors.

Anyone have any thoughts on why I'm seeing this error?

Thanks...

EDIT:

Since it seems likely my issues are related to my SSH server, the main loop is below:

        proc = subprocess.Popen(command, stdin=subprocess.PIPE,
                stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        while True:
            try:
                r_ready, w_ready, x_ready = select.select(
                    [channel, proc.stdout, proc.stderr], [proc.stdin], [])
            except Exception, e:
                print e
                print 'channel: ' + str(channel)
                print 'proc: ' + str(proc)

            if channel in r_ready and channel.recv_ready():
                data = channel.recv(128)
                if len(data) > 0:
                    print 'IN>channel ' + repr(data)
                    proc.stdin.write(data)
                else:
                    pass

            if proc.stdout in r_ready:  
                data = proc.stdout.read(1)
                channel.sendall(data)

            if proc.stderr in r_ready:

                data = proc.stdout.read(1)
                if len(data) > 0:
                    channel.sendall(data)

                else:
                    print "Encountered empty stderr, breaking"
                    break                       

        print 'will close'
        channel.shutdown(2)
        channel.close()

More Information

I thought it might be helpful to see the actual communication. This is at it appears on the server side, since the git client doesn't allow you to see nearly this much.

git-receive-pack /home/www/data/project/heyworld/

OUT >>
00721ee2436e45c80236878132dc87d9e9fee6a81de5 refs/heads/master\x00 report-status delete-refs side-band-64k ofs-delta\n0000

IN >>
00841ee2436e45c80236878132dc87d9e9fee6a81de5 6054b3358787bafd1d96c0fdfbf016d620ccdf09 refs/heads/master\x00 report-status side-band-64k0000

IN >>
PACK\x00\x00\x00\x02\x00\x00\x00\x03\x96\x0ex\x9c\xa5\x8cM\x0e\xc2 \x14\x06\xf7\x9c\x82\x0b\xd8<(?\x8f\xc4\x18\xf7n\xbc\x02\xc2\x87%\x16\xdb4\xb8\xf0\xf66\xbd\x82\xcb\x99d\xa6o\x80\x846\xd9!)\x1b\x0b\xb1\r1$dO\x05\xa6\xb0\xa3@\x06%D<\xb2\x16k\xdc\xf0\xeeRa/F\x07c\x13\x93\x1e\x1d{V\xa3\xce\x89}\x0e\x08\x05p\x91U\x86\x15\xf1\xd3\xa7e\x93\xf7\xa9\xceu\x95\xb7\xda\x1a\xbe\xf2\xbc\x1e8\xbc\x0e\xbc>[\xac\xf3\x90\x96v\x91J\xfb`X\xb3V\xf2D\x96H\xec\xb6\xd5\xde\xf1\xc7B4,\xe2\x07\xff\x8aF\xba\xaf\x01x\x9c340031Q\xc8H\xaddP\xd8P\xfcmzGg\x8aY\xc4\x8e\xad\xb1<\xca\x1b\xa3\x93\xee\xbd\x05\x00\xa8\xb4\x0c\x9by\xd3\xfe\xa0C\x86fU\x18\xbe\xa5\x86\xac5*\xf7\x11\x89\x8b9$x\x9c\x0b\x8b\x9a\x10\xc6\x92\x9b\x9a\xcf\x05\x00\x0f\xb2\x02\xe6=\x12?\xde\x1f\x9a=v\x0c3c\xf66\xc6\xcc1y\xe4\xb8\xa0

OUT >>
0030\x01000eunpack ok\n009krf/ed/atr0000

CLOSE CONNECTION

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

握住我的手 2024-09-17 10:52:18

您可能知道,这可能是一堆问题!

  • 我最初的猜测是服务器上的某些权限不正确,因此无法更新一些非关键信息
  • 也可能还有其他一些问题...

几个简单的问题/建议:

  • 您可以成功手动运行命令吗?
  • 尝试将 --verbose 标志添加到推送命令中(即 git push --verbose origin/master)

添加 verbose 标志可能会让您快速解决问题。

As you probably know, this could be a bunch of issues!

  • My initial guess is that some permissions are not correct on the server and thus could not update some non-critical information
  • Could also some other issues as well...

Couple quick questions/suggestions:

  • Can you run the command manually successfully?
  • Try adding the --verbose flag to the push command (ie. git push --verbose origin/master)

Adding the verbose flag might put you on the fast track to figuring out the issue.

拥醉 2024-09-17 10:52:18

git 邮件列表上的一位非常乐于助人的用户接受了他认为是在黑暗中进行的尝试并得到了正确的结果。

我没有返回退出代码,这是 Git 在推送时所期望的。这解决了问题。

A very helpful user on the git mailing list took what he thought was a stab in the dark and got it right.

I wasn't returning the exit code, which Git expects on pushes. That solved the problem.

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