git add 到裸仓库

发布于 2024-11-23 20:36:11 字数 990 浏览 2 评论 0原文

我在服务器上使用 git init --bare 创建了一个存储库,我想将一个分支推送到它。

git push origin Dev

但我明白

remote fatal: you are a branch waiting to be born.

我做错了什么?
如果我不使用 --bare ,它似乎可以工作,但我认为这就是我应该使用的。

编辑: 如果我的服务器上有 post-recieve 挂钩,我只会收到此错误。 我的 post-recieve 钩子中有这个:

#!/bin/sh
GIT_WORK_TREE=/var/www/UML git checkout -f

我想要做的就是在推送到远程时更新网络服务器

和我的 git 配置:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[gui]
    wmstate = normal
    geometry = 887x427+25+25 330 192
[branch "master"]
[branch "Dev"]
[remote "origin"]
    url = ssh://[email protected]/GR
    fetch = +refs/heads/*:refs/remotes/origin/*

I greated a repository with: git init --bare on a server and I want to push a branch to it.

git push origin Dev

But I get

remote fatal: you are a branch waiting to be born.

What am I doing wrong?
It seems to work if I dont use --bare, but I think thats what I should be using.

EDIT:
I am only getting this is error if I have a post-recieve hook on the server.
I have this in my post-recieve hook:

#!/bin/sh
GIT_WORK_TREE=/var/www/UML git checkout -f

what I want this all to do is update the webserver when I push to the remote

And my git config:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[gui]
    wmstate = normal
    geometry = 887x427+25+25 330 192
[branch "master"]
[branch "Dev"]
[remote "origin"]
    url = ssh://[email protected]/GR
    fetch = +refs/heads/*:refs/remotes/origin/*

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

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

发布评论

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

评论(1

恬淡成诗 2024-11-30 20:36:11

您是否先克隆了远程(裸)存储库或正确设置了远程origin?名为 Dev 的分支是否存在并且有提交?确保该分支上至少有一次提交。


在你的钩子中尝试git reset --hard而不是git checkout -f。还可以尝试在末尾添加 exit 0; (尽管这只会隐藏之前语句的退出代码)。你的钩子里的东西出了问题。您的钩子脚本上是否设置了可执行位?
如果直接在服务器上执行钩子脚本而不需要git干预会发生什么?

还要确保您的 git 进程在 /var/www/UML 目录中具有写入权限,因为该脚本是由运行 git 守护进程的用户/组执行的

have you cloned the remote (bare) repository first or set the remote origin properly? does a branch with the name Dev exist and have commits? make sure to have at least one commit on that branch.


in your hook try git reset --hard instead of git checkout -f. also try adding exit 0; at the end (although that will just hide the exit code of the statement before). something in your hook is failing. is the executable bit set on your hook script?
what happens if you execute the hook script directly on the server without git intervention?

also make sure your git process has write permissions in your /var/www/UML directory, as the script is executed by the user/group who runs git daemon

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