[英]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.