git 检查更新文件_Git通过差异比对快速打包待更新文件(SQL)
生活随笔
收集整理的這篇文章主要介紹了
git 检查更新文件_Git通过差异比对快速打包待更新文件(SQL)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
本文實現(xiàn)主要用到的命令:
我是在X度上搜不到完整的方案(單個命令的用法自行X度),結(jié)合多方面雜亂的搜索結(jié)果、自己Windows7環(huán)境實驗得出的結(jié)論。
因此直接上我本地可執(zhí)行的代碼,后續(xù)如果有人感興趣,可以再展開詳細:
#!/bin/bash #resetsqlDir=`pwd` LOG_FILE=log_git_latest.txtif [[ ! -f $LOG_FILE ]]; thenecho 更新日志文件不存在!進行首次記錄……echo "-------------`date +%Y-%m-%d` This is the beginning of the file.-------------" > $LOG_FILEfirst_time_latest=`git log --pretty=format:'%h %cd %cn %s 明細:%b' --date=format:'%Y-%m-%d_%H%M%S' -1`echo $first_time_latest# 往首行插入記錄sed -i '1i'"$first_time_latest"'' $LOG_FILE fiecho $sqlDir echo 上次獲取到最新的commit、時間: # 讀取首行記錄 last_time_latest=`head -1 log_git_latest.txt` echo $last_time_latestecho 開始獲新... git pull 1> /dev/nullecho 本次獲取到最新的commit、時間: this_time_latest=`git log --pretty=format:'%h %cd %cn %s 明細:%b' --date=format:'%Y-%m-%d_%H%M%S' -1` echo $this_time_latestSQL_PACK_FILE=`date +%Y-%m-%d_%H%M%S`.tar.gz echo 本次更新將打包生成 [ $SQL_PACK_FILE ],包含以下文件: #git diff ${last_time_latest:0:7}..${this_time_latest:0:7} --name-only git diff ${last_time_latest:0:7}..${this_time_latest:0:7} --name-only --diff-filter=ACMR | grep .sql | xargs tar -zcvf $SQL_PACK_FILE# 往首行插入記錄 sed -i '1i'"$this_time_latest"' 生成的SQL更新包:'"$SQL_PACK_FILE"'' $LOG_FILEGIT的log、diff命令可能出現(xiàn)“中文文件名亂碼”的問題,需要進行如下配置:
git config --global core.quotepath false # 顯示 status 編碼 git config --global gui.encoding utf-8 # 圖形界面編碼 git config --global i18n.commit.encoding utf-8 # 提交信息編碼 git config --global i18n.logoutputencoding utf-8 # 輸出 log 編碼如果是Linux,因為 git log 默認使用 less 分頁,所以需要對 less 命令進行 utf-8 編碼:
export LESSCHARSET=utf-效果圖,加示意箭頭總結(jié)
以上是生活随笔為你收集整理的git 检查更新文件_Git通过差异比对快速打包待更新文件(SQL)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java使用comms-net jar包
- 下一篇: mysql调试.net_需要有关使用.N