[英]How to push a GitHub branch to server
在我的项目中,我创建了一个名为dev
的新分支,并希望将该分支推送到服务器,但它似乎继续推动主分支。
GitHub的:
在服务器上:
我的工作流程
多数民众赞成我想做的事。
我目前无法将Dev分支推送到Staging服务器:dev.example.com
这是我的本地git配置文件:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[branch "origin"]
remote = git@github.com:xxxx/xxxxxxxx.git
merge = refs/heads/master
[remote "origin"]
url = git@github.com:daugaard47/povertyresolutions.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "production"]
url = ssh://root@140.xx.xx.xx/var/repo/site.git
fetch = +refs/heads/*:refs/remotes/production/*
[remote "staging"]
url = ssh://root@140.xx.xx.xx/var/repo/dev.git
fetch = +refs/heads/*:refs/remotes/dev/*
[branch "dev"]
remote = staging
merge = refs/heads/dev
在我的服务器上,我有一个repo目录: dev.git
& site.git
在我推送到我的Dev Branch
我运行git push staging
来推送到我的dev.example.com,但它似乎推动了我的Git Master
分支。
这是我的dev.git/hooks/post-receive
文件中的内容:
#!/bin/sh
git --work-tree=/var/www/dev --git-dir=/var/repo/dev.git checkout -f
这是在我的site.git/hooks/post-receive
文件中:
#!/bin/sh
git --work-tree=/var/www/laravel --git-dir=/var/repo/site.git checkout -f
我确定我错过了一些简单的东西,但任何帮助都会受到赞赏。
我建议使用以下分支配置:
git config branch.master.remote production
git config branch.dev.remote staging
和以下远程refspec配置:
git config remote.production.push refs/heads/master:refs/remotes/production/master
git config remote.staging.push refs/heads/dev:refs/remotes/staging/dev
在服务器端,我建议检查钩子正在更新哪些遥控器; post-receive
hook 用标准输入上的列表提供,所以将检查添加到你的钩子:
while read old_hash new_hash ref; do
if [ "$ref" = refs/heads/master ]; then
git … checkout …
fi
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.