前情摘要
随着小明公司项目越做越大,加之使用微服务架构,导致公司的项目越拆越多,在团队里的负责十几个service,这时出现了一个问题,service数量多了,每天同步代码是个非常头疼的问题,由于在业务上升期,每个service都在不断迭代,所以虽然同步代码的工作既重复又没有技术含量但是又不得不做,小明同学深受其害!!!
解决问题
小明同学想着如果能自动执行这些重复代码就可以省很多事,就这样开始着手写脚本。。。
#!/bin/
time=$(date "+%Y-%m-%d %H:%M:%S")
echo "##################${time} Begin Sync Code#######################" >> syncLog.txt 2>&1
##common
cd common
common_branch_name=`git symbolic-ref --short -q HEAD`
echo "###common's current branch is ${common_branch_name}###" >> ../syncLog.txt 2>&1
git checkout master >> ../syncLog.txt 2>&1
git fetch upstream >> ../syncLog.txt 2>&1
git rebase upstream/master >> ../syncLog.txt 2>&1
git push >> ../syncLog.txt 2>&1
git checkout $common_branch_name >> ../syncLog.txt 2>&1
git rebase master >> ../syncLog.txt 2>&1
git push >> ../syn