您的位置:首页 > 其它

git 导出版本之间差异文件

2017-10-24 13:13 441 查看

查看 commit id

首先用
git log
查看版本库日志,找出需要导出的 commit id

$ git log --pretty=oneline
456bcbccd91278f7fdf6bf11bc73c4e3a6193c7f (HEAD -> www.xxx.com) 搜索添加翻页
4416b97c1c67efb83f63bd60af8244105471f3db Merge branch 'master' into www.xxx.com
ffd7d3c29d92dcbb6239401dd997a38d6adf554b (master) 将分页视图发布到项目中,方便自定义分页
68ea66ca296f41e62951ae96aa59fdd7b2848317 给搜索路由加上名称
93593adac0bce680e63d202057c8128ccd9ea82b (origin/www.xxx.com) 调整页脚的网址
f07871038329dccf00a4deb66d7898bd1015c2e1 修正首页轮播图小点的问题
f5ce56385f0cff7817619c7577600ea995f10994 Merge branch 'master' into www.xxx.com
7b7354817681392cf3696629bb9032960216ade9 (origin/master) debug:从栏目复制导航的时候,会报错
690c7826a076b49b401d55534d83263b8b15348a Merge branch 'master' into www.xxx.com
003dc9aa6ed0c4b6009e782e87585bd2eaefddac 文章添加 seo 信息,栏目删除 seo 标题字段
12f2da2c00ececb59eab05ed34c259d6167fd41a 添加文章、栏目 seo 信息
e11b00c72a669f13de51f80ce4c1152500eed250 完成文章详情页面套模板
697013ee07c4904e954e468431d8e54634111a3e 合并主干
c6718cf018b62178711ed482aa7509d16e6c5e21 打开文章、栏目添加点击量
aa300af58a0c929ff6a6ac97a949fea4146cca7c Merge branch 'master' into www.xxx.com


找出差异文件

使用
git diff
命令可以查看提交之间的插件,使用
--name-only
参数只显示文件名

$ git diff 456bcb 93593a --name-only
public/js/index.js
resources/views/index.blade.php
resources/views/public/pagination.blade.php
resources/views/search.blade.php
resources/views/vendor/pagination/bootstrap-4.blade.php
resources/views/vendor/pagination/default.blade.php
resources/views/vendor/pagination/semantic-ui.blade.php
resources/views/vendor/pagination/simple-bootstrap-4.blade.php
resources/views/vendor/pagination/simple-default.blade.php


输出结果就是所有的差异文件,下面再使用
xargs
将文件进行下一步处理

将差异文件打包

$ git diff 456bcb 93593a --name-only | xargs tar -czvf ../update.tar.gz
public/js/index.js
resources/views/index.blade.php
resources/views/public/pagination.blade.php
resources/views/search.blade.php
resources/views/vendor/pagination/bootstrap-4.blade.php
resources/views/vendor/pagination/default.blade.php
resources/views/vendor/pagination/semantic-ui.blade.php
resources/views/vendor/pagination/simple-bootstrap-4.blade.php
resources/views/vendor/pagination/simple-default.blade.php


这样,../update.tar.gz 文件就有所有更新的文件

直接复制出差异文件

$ git diff 456bcb 93593a --name-only | xargs -t -i{} cp --parents {} ../update
cp --parents public/js/index.js ../update
cp --parents resources/views/index.blade.php ../update
cp --parents resources/views/public/pagination.blade.php ../update
cp --parents resources/views/search.blade.php ../update
cp --parents resources/views/vendor/pagination/bootstrap-4.blade.php ../update
cp --parents resources/views/vendor/pagination/default.blade.php ../update
cp --parents resources/views/vendor/pagination/semantic-ui.blade.php ../update
cp --parents resources/views/vendor/pagination/simple-bootstrap-4.blade.php ../update
cp --parents resources/views/vendor/pagination/simple-default.blade.php ../update


xargs -t -i{} cp --parents {} ../update
的参数说明

-t:显示执行的命令

-i{}:将前面的输入作为一个占位符
{}
在后面使用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  git 导出 差异文件