2021년 4월 28일 수요일

[git] git에 있는 목록 patch 파일 만들기.

---------------------------------------
git 특정 커밋에 대한 패치 생성 방법
---------------------------------------

git show commitID > name.patch
ex)
git show d9473f4ff38752a94017eceba8646d3813743edf > 0001_app_stach.patch


---------------------------------------
git 특정 커밋부터 지정한 개수만큼 패치 생성 방법
---------------------------------------

git format-patch -개수 commitID
ex)
git format-patch -3 7d7ef5d646e4c25047de18a581dc5c30527cb8da

생성된 파일
0001-aaaaa.patch // 지정된 commitId 2개 전 commit
0002-bbbbb.patch // 지정된 commitId 1개 전 commit
0003-ccccc.patch // format-patch 로 지정된 commitId

git의 로그 확인
peter$ git log -5
commit 813d065506f3dd2b1bf671c8920f8ad13f9f1818
Author:
Date: Wed Apr 28 13:00:08 2021 +0900
commit 내용 두번째

commit a3cc141e59932d9b85840acc71ccd1e4800fca7b
Author:
Date: Tue Apr 27 16:16:02 2021 +0900
commit 내용 첫번째

commit 7d7ef5d646e4c25047de18a581dc5c30527cb8da
Author:
Date: Fri Apr 16 15:00:25 2021 +0900
commit 내용 ccccc 패치 파일 생성 기준

commit 1147b12ff08b5e78d6ff495a98d3363833eb7dc3
Author:
Date: Tue Apr 13 15:57:00 2021 +0900
commit 내용 bbbbb

commit 753efad493ff138b6fd8b71e794dee252e18c1f0
Author:
Date: Tue Apr 13 09:37:37 2021 +0900
commit 내용 aaaaa

---------------------------------------
패치 파일 적용 방법
---------------------------------------

patch -p1 < 0001-aaaaa.patch