git add 到裸仓库
我在服务器上使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否先克隆了远程(裸)存储库或正确设置了远程
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 nameDev
exist and have commits? make sure to have at least one commit on that branch.in your hook try
git reset --hard
instead ofgit checkout -f
. also try addingexit 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