查看 commit id
首先用 git log 查看版本庫日誌,找出需要匯出的 commit id
$ git log --pretty=oneline456bcbccd91278f7fdf6bf11bc73c4e3a6193c7f (HEAD -> www.xxx.com) 搜尋添加翻頁4416b97c1c67efb83f63bd60af8244105471f3db Merge branch 'master' into www.xxx.comffd7d3c29d92dcbb6239401dd997a38d6adf554b (master) 將分頁檢視發布到項目中,方便自訂分頁68ea66ca296f41e62951ae96aa59fdd7b2848317 給搜尋路由加上名稱93593adac0bce680e63d202057c8128ccd9ea82b (origin/www.xxx.com) 調整頁尾的網址f07871038329dccf00a4deb66d7898bd1015c2e1 修正首頁輪播圖小點的問題f5ce56385f0cff7817619c7577600ea995f10994 Merge branch 'master' into www.xxx.com7b7354817681392cf3696629bb9032960216ade9 (origin/master) debug:從欄目複製導航的時候,會報錯690c7826a076b49b401d55534d83263b8b15348a Merge branch 'master' into www.xxx.com003dc9aa6ed0c4b6009e782e87585bd2eaefddac 文章添加 seo 資訊,欄目刪除 seo 標題欄位12f2da2c00ececb59eab05ed34c259d6167fd41a 添加文章、欄目 seo 資訊e11b00c72a669f13de51f80ce4c1152500eed250 完成文章詳情頁面套模板697013ee07c4904e954e468431d8e54634111a3e 合并主幹c6718cf018b62178711ed482aa7509d16e6c5e21 開啟文章、欄目添加點擊量aa300af58a0c929ff6a6ac97a949fea4146cca7c Merge branch 'master' into www.xxx.com
找出差異檔案
使用 git diff 命令可以查看提交之間的外掛程式,使用 --name-only 參數只顯示檔案名稱
$ git diff 456bcb 93593a --name-onlypublic/js/index.jsresources/views/index.blade.phpresources/views/public/pagination.blade.phpresources/views/search.blade.phpresources/views/vendor/pagination/bootstrap-4.blade.phpresources/views/vendor/pagination/default.blade.phpresources/views/vendor/pagination/semantic-ui.blade.phpresources/views/vendor/pagination/simple-bootstrap-4.blade.phpresources/views/vendor/pagination/simple-default.blade.php
輸出結果就是所有的差異檔案,下面再使用 xargs 將檔案進行下一步處理 將差異檔案打包
$ git diff 456bcb 93593a --name-only | xargs tar -czvf ../update.tar.gzpublic/js/index.jsresources/views/index.blade.phpresources/views/public/pagination.blade.phpresources/views/search.blade.phpresources/views/vendor/pagination/bootstrap-4.blade.phpresources/views/vendor/pagination/default.blade.phpresources/views/vendor/pagination/semantic-ui.blade.phpresources/views/vendor/pagination/simple-bootstrap-4.blade.phpresources/views/vendor/pagination/simple-default.blade.php
這樣,../update.tar.gz 檔案就有所有更新的檔案 直接複製出差異檔案
$ git diff 456bcb 93593a --name-only | xargs -t -i{} cp --parents {} ../updatecp --parents public/js/index.js ../updatecp --parents resources/views/index.blade.php ../updatecp --parents resources/views/public/pagination.blade.php ../updatecp --parents resources/views/search.blade.php ../updatecp --parents resources/views/vendor/pagination/bootstrap-4.blade.php ../updatecp --parents resources/views/vendor/pagination/default.blade.php ../updatecp --parents resources/views/vendor/pagination/semantic-ui.blade.php ../updatecp --parents resources/views/vendor/pagination/simple-bootstrap-4.blade.php ../updatecp --parents resources/views/vendor/pagination/simple-default.blade.php ../update
xargs -t -i{} cp --parents {} ../update 的參數說明 -t:顯示執行的命令 -i{}:將前面的輸入作為一個預留位置 {} 在後面使用