Git 一键生成补丁 old folder new folder update.path

Git 一键生成补丁 old folder new folder update.path
原理很简单,看下面脚本,使用也很简单

$ git log
commit 75df2c656ba0ff4654515922f1d26c102577c9e6
Author: DevinLow <gang_liu1987@163.com>
Date:   Thu Sep 29 15:21:39 2016 +0800

    usb 去抖

commit e46d98b2818121b3639bc8a6cab0258581c513aa
Author: DevinLow <gang_liu1987@163.com>
Date:   Thu Sep 29 15:01:09 2016 +0800

    init project


$./gitdiff.sh  e46d98b28181...   75df2c656ba..... 
Archive:  new.zip
75df2c656ba0ff4654515922f1d26c102577c9e6
   creating: ./new/mediatek/
   creating: ./new/mediatek/kernel/
   creating: ./new/mediatek/kernel/drivers/
   creating: ./new/mediatek/kernel/drivers/usb20/
  inflating: ./new/mediatek/kernel/drivers/usb20/musb_core.c  
Archive:  old.zip
e46d98b2818121b3639bc8a6cab0258581c513aa
   creating: ./old/mediatek/
   creating: ./old/mediatek/kernel/
   creating: ./old/mediatek/kernel/drivers/
   creating: ./old/mediatek/kernel/drivers/usb20/
  inflating: ./old/mediatek/kernel/drivers/usb20/musb_core.c  
liugang@ospicon-ubuntu:~/8127_mlc_kk$ 
在上一层的目录中就会生成 update目录
$ ls  ../update/ -l
ls: 初始化月份字符串出错
总用量 12
drwxrwxr-x 3 liugang liugang 4096  99 18:55 new
drwxrwxr-x 3 liugang liugang 4096  99 18:55 old
-rw-rw-r-- 1 liugang liugang 1031  99 18:55 update.path
#!/bin/bash
targetfolder=../update
targetname=update.zip
if [ $# != 2 ] ; then
        echo "USAGE: $0 OLD_ID NEW_ID" 
        exit 1;
fi
mkdir -p $targetfolder
git diff $1 $2 >../update/update.path
git archive -o ../update/new.zip $2 $(git diff --name-only $1 $2)  #新版本的差异文件
git archive -o ../update/old.zip $1 $(git diff --name-only $2 $1)  #旧版本的差异文件
cd ../update
unzip -o -d ./new/ new.zip
unzip -o -d ./old/ old.zip
rm new.zip old.zip
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值