2019年9月2日 星期一

Git 學習 - git format-patch 和 git am 搬移資料

透過 git format-patch 來產生一連串的 patch 檔案, 接着透過 git am 來匯入並加入每一個 patch
這功能對於 repo 搬移資料, 非常強大也非常方便 (不需要自己手動匯入每一筆 patch)

  • 製作 Patch

    `git format-patch --root -o ./patches`

    從第一筆 commit 開始產生 Patch 檔案, 輸出到 patches 資料夾底下

    `git format-patch -2 -o ./patches`

    產生最近 2 筆 commit 的 patch 檔案, 輸出到 patches 資料夾底下

    `git format-patch f259d..93ee9 -o ./patches`

    產生指定範圍 coomit 的 patch 檔案, 輸出到 patches 資料夾底下




  • 匯入 Patch

    `git am --abort`

    取消前一次匯入動作, 並清除錯誤結果

    `git am ./patches`

    匯入 patches 資料夾底下所有的 patch 檔案

沒有留言:

張貼留言