我写运行作为我的我裸露的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