检出子目录中的所有文件 [英] Checking out all files in sub directory
问题描述
我试图检出特定目录"code/app"中的所有文件和子目录,但是git给我code/app目录及其内容.我只想要它的内容.我想在接收后的git钩子中使用它.
I'm trying to checkout all files and subdirectories in a specific directory "code/app" but git gives me code/app the directory plus its contents. I just want its contents. I would like to use this in a post-receive git hook.
git checkout -f master -- code/app
我也尝试了以下方法,但无济于事
I also tried the following to no avail
git checkout -f master -- code/app/*
git checkout -f master -- code/app/.
如何获得上述预期行为?
How can I get the expected behavior stated above?
更新:
接收后
#!/usr/bin/env ruby
# post-receive
# Read STDIN
from, to, branch = ARGF.read.split " "
if (branch =~ /master$/)
puts "Received branch #{branch}, deploying."
# Copy files to deploy directory
deploy_to_dir = File.expand_path('../development')
dir_to_checkout = '06\ -\ Code/app/'
`GIT_WORK_TREE="#{deploy_to_dir}" git checkout -f master -- #{dir_to_checkout}`
puts "DEPLOY: master(#{to}) copied to '#{deploy_to_dir}'"
exit
end
# Only deploy if pre-production branch was pushed
if (branch =~ /pre-production$/)
puts "Received branch #{branch}, deploying."
# Copy files to deploy directory
deploy_to_dir = File.expand_path('../staging')
dir_to_checkout = '06\ -\ Code/app/'
`GIT_WORK_TREE="#{deploy_to_dir}" git checkout -f pre-production -- #{dir_to_checkout}`
puts "DEPLOY: pre-production(#{to}) copied to '#{deploy_to_dir}'"
exit
end
if (branch =~ /production$/)
puts "Received branch #{branch}, deploying."
# Copy files to deploy directory
deploy_to_dir = File.expand_path('../')
dir_to_checkout = '06\ -\ Code/app/'
`GIT_WORK_TREE="#{deploy_to_dir}" git checkout -f production -- #{dir_to_checkout}`
puts "DEPLOY: production(#{to}) copied to '#{deploy_to_dir}'"
exit
end
推荐答案
@torek,@jthill我从您的帖子中学到了很多东西.那里有很棒的主意.但是,我选择使用 PM2 ,它可以从客户端计算机上很好地完成此任务.我还发现 shipit 作为我问题中说明的问题的另一种选择.
@torek, @jthill I've learnt quite a bit from your posts. There are great ideas in there. I, however, chose to go with PM2 which does this fairly well from a client machine. I've also found shipit as another alternative the problem illustrated in my question.
这篇关于检出子目录中的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!