Git post-receive只签出那些在推送中被修改/添加的文件? [英] Git post-receive to checkout only those files that have been modified/added in the push?

查看:227
本文介绍了Git post-receive只签出那些在推送中被修改/添加的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在我的git仓库中使用post-receive脚本,并使用以下命令来检出仓库中的所有文件:

 #!/ bin / sh 
GIT_WORK_TREE = / var / www / www.example.org git checkout -f

我想要做类似的事情,但只检出已在推送中修改或添加的文件。一旦文件被检出后,接收后脚本将对这些文件运行一些其他命令,并在最后删除文件,这样该目录将是空的。



这可能吗?

解决方案

您可以使用 git diff 你的文件列表

  git diff --name-only from..to 

收到后这将是我认为的

  git diff --name-only $ 1 .. $ 2 

,因为这个钩子接收到 oldrev newrev ref 标准输入

I have been using post-receive scripts in my git repositories with the following commands to checkout all of the files in the repository:

#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f

I am wanting to do something similar but only checkout the files that have been modified or added in the push. Once the files have been checked out the post-receive script will then run some other commands on these files and remove the files at the end so that the directory will be empty.

Is this possible?

解决方案

you can use git diff to give you a list of files

git diff --name-only from..to

in a post-receive hook that'll be I think

git diff --name-only $1..$2

as this hook receives oldrev, newrev and ref on standard input

这篇关于Git post-receive只签出那些在推送中被修改/添加的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆