2011-08-04 42 views
2

我想將補丁應用到當前目錄中的文件。修補程序文件中的路徑僅顯示/ FILETOPATCH.something b/FILETOPATCH.something。如果我在git中使用它,它不起作用。要修補的文件和.patch文件位於相同的目錄中。爲什麼git不會在當前目錄中找到要修補的文件?

我嘗試了許多變體中的--directory和-p選項,但沒有成功。

使用patch -p1 < patchfile.patch工作正常。

如果我從.patch文件中的存儲庫根目錄設置絕對路徑,它也適用於git apply,但肯定有一種方法無需編輯補丁文件。

這將git的工作申請

diff --git a/htdocs/something/whatever/file.code b/htdocs/something/whatever/file.code 
index 385f3f4..07d8062 100644 
--- a/htdocs/something/whatever/file.code 
+++ b/htdocs/something/whatever/file.code 
... 
PATCH DATA 
... 

但不是這個(這是原件)

diff --git a/file.code b/file.code 
index 385f3f4..07d8062 100644 
--- a/file.code 
+++ b/file.code 
... 
PATCH DATA 
... 

任何想法如何獲得git的申請工作,而不改變補丁文件?

回答

1

如何製作diff文件?

嗯,這是我如何應用補丁的過程。希望它能幫到你

git diff --full-index <SHAsum of commit A> <SHAsum of commit B> > change.patch  (full index for binary file) 
git apply --check --verbose --summary change.patch (check if it is in good patch or not) 
git apply --verbose change.patch 
相關問題