Linux 일반

git diff 한 것을 patch하기

bumnux 2011. 10. 27. 16:18
[펌] http://jang574.tistory.com/entry/git-diff-%ED%95%9C-%EA%B2%83%EC%9D%84-patch%ED%95%98%EA%B8%B0

git 과 patch 툴 사용 팁이다.

git diff --no-prefix > patchfile # 패치파일 생성
cd path/to/top                     # 패치하고자 하는 소스 위치
patch -p0 < patchfile            # 패치 적용

--no-prefix 옵션 없이 패치파일 생성한 경우 -p1 옵션으로 패치 적용 (패치내용의 a/ b/ path prefix 무시)
git diff > patchfile                 # 패치파일 생성
cd path/to/top                     # 패치하고자 하는 소스 위치
patch -p1 < patchfile            # 패치 적용