#!/bin/bash# # Usage:# ./run_script.sh old_branch new_branch# ./run_script.sh old_commit new_commit# Before running the script, you must commit what you have modified.# After the script is done, you should checkout back to the branch you use.
dt=$(date +%Y%m%d)
# SET the temp path:
FN="/home/nick/tmp/$dt"# SET the git path:
gitpath='/home/nick/rockchip/box_4.4.2_0519/'if [ $#-eq2 ];thencd$gitpath#1 find out the diff file name:
git diff $1$2 --name-only > $FN.txt
#2 del last line:#sed -i '$d' $FN.txt
target="/home/nick/tmp/diff_$1_$2_$dt"# Make the target directory:
mkdir $target#3 switch to new branch:
git checkout $2#4 export the new files:
/usr/bin/rsync -rltDv --files-from=$FN.txt $gitpath$target/new
#5 switch to old branch:
git checkout $1#6 export the old files:
/usr/bin/rsync -rltDv --files-from=$FN.txt $gitpath$target/old
### tar as a tar.gz file.
tar -czPf $target/code_$1_$2_$dt.tar.gz $targetecho"tar ok!";
elseecho"Usage:
./run_script.sh old_branch new_branch
./run_script.sh old_commit new_commit
Note:
Before running the script, you must commit what you have modified.
After the script is done, you should checkout back to the branch you use.
"fi