我寫運行作爲我的我裸露的git倉庫內post-update
鉤一個非常簡單的「部署」腳本。GIT&Ruby:如何從ruby腳本中取消設置GIT_DIR變量?
的變量如下
live domain = ~/mydomain.com
staging domain = ~/stage.mydomain.com
git repo location = ~/git.mydomain.com/thisrepo.git (bare)
core = ~/git.mydomain.com/thisrepo.git
core == added remote into each live & stage gits
兩個live
& stage
已初始化的git回購(非裸)和我已經加入我的裸回購作爲遠程他們每個人(命名爲core
),以便git pull core stage
或git pull core live
將從core
回購的各branch
拉更新的文件。
的腳本如下:
#!/usr/bin/env ruby
# Loop over each passed in argument
ARGV.each do |branch|
# If it matches the stage then 'update' the staging files
if branch == "refs/heads/stage"
puts ""
puts "Looks like the staging branch was updated."
puts "Running a tree checkout now…"
puts ""
`cd ~/stage.mydomain.com`
`unset GIT_DIR` # <= breaks!
`git pull core stage`
puts ""
puts "Tree pull completed on staging branch."
puts ""
# If it's a live site update, update those files
elsif branch == "refs/heads/live"
puts ""
puts "Looks like the live branch was updated."
puts "Running a tree checkout now…"
puts ""
`cd ~/mydomain.com`
`unset GIT_DIR` # <= breaks!
`git pull core live`
puts ""
puts "Tree checkout completed on live branch."
puts ""
end
end
我試圖適應從this bash script here文件的「更新」,它使用unset GIT_DIR
運行下一個混帳命令git pull core stage
例如。 core
在服務器上的其他文件夾中添加的我bare
回購remote
。在執行上面的腳本,我發現了以下錯誤
然而,當:
remote: hooks/post-update:35: command not found: unset GIT_DIR
remote: fatal: /usr/lib/git-core/git-pull cannot be used without a working tree.
有沒有辦法做同樣的事情,unset GIT_DIR
在我的Ruby腳本中的bash腳本?
非常感謝,
Jannis
這就像魔術!非常感謝你。現在就完成並運行!關閉以瞭解如何通過將特殊格式的註釋傳遞到提交說明中來實現同樣的效果:)我想知道是否可以使用'[update:live]'或'[update:stage]'來觸發這個'pull '行動... – Jannis 2011-04-03 00:41:13
剛剛救了我一大堆挫折 - 謝謝!沒有意識到這些變數有這樣的意義! – 2013-05-28 18:31:57