Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

拿到git patch要怎麼用一般patch指令merge?

如果你的codebase工作環境沒有使用git作管理, 你要怎麼做從git產生的patch呢?

首先要先知道diff 與 patch 的關係, 傳統的linux裡面, .patch檔案是透過diff產生的

Diff 和 Patch 的簡易操作使用筆記:(參考: Tsung’s Blog)
diff -Naur file1 file2 > project.patch # Diff 產生 patch, 檔案, 資料夾都可以
# 或 diff -Naur dir1 dir2 > project.patch # Diff 產生 patch
patch -p0 < project.patch # 將 patch 寫入 patch -p0 < project.patch # 再做一次會詢問是否自動加上 -R 來移除之前 patch 寫入的(恢復回上一步的資料) patch -R -p0 < project.patch # 移除回復修改 (同上一步驟, 此次就是確定要移除上次的 project.patch)

造著傳統方式以 “patch -p0 <" 接patch 檔 然後會跳出 "File to patch:" 要求你輸入該檔的位置 你就複製貼上輸入下去就好了

can’t find file to patch at input line 79
Perhaps you used the wrong -p or –strip option?
The text leading up to this was:
|diff –git a/user/hal/user/xxxxx.h b/user/hal/user/xxxxx.h
|index 0a3889f..9c92c36 100644
|— a/user/hal/user/xxxxx.h
|+++ b/user/hal/user/xxxxx.h
File to patch: user/hal/user/xxxxx.h <===複製上面貼到這裡 patching file user/hal/user/xxxxx.h

PS: 如果你有用git管理自己的codebase
請直接參考此篇 http://eeepage.info/git-patch-merge/