git pull & patch 간략 정리

Posted 2009/02/18 19:10 by kdsoo

1. modified 파일이 있나 확인.

kdsoo@chromatix:/home/share/GIT/OMAP3430/linux-2.6.29-rc3-omap$ git status

# On branch master

# Changed but not updated:

#   (use "git add <file>..." to update what will be committed)

#

#   modified:   arch/arm/mach-omap2/board-xxx.c

#   modified:   arch/arm/mach-omap2/mux.c

#   modified:   arch/arm/plat-omap/include/mach/mux.h

#   modified:   drivers/media/video/xxxx.h

#

# Untracked files:

#   (use "git add <file>..." to include in what will be committed)

#

#   090202

#   work.patch

#   work.patch2

no changes added to commit (use "git add" and/or "git commit -a")

 

modified 파일이 있으면 pull 이 안될수 있습니다.

 

2. modified 파일이 있으면 patch 뜬다.

kdsoo@chromatix:/home/share/GIT/OMAP3430/linux-2.6.29-rc3-omap$ git diff > work.patch

 

패치가 work.patch 파일로 저장됩니다.

 

3. local git repository를 리셋

가장 마지막으로 pull 해왔던 상태로 리셋합니다.

 kdsoo@chromatix:/home/share/GIT/OMAP3430/linux-2.6.29-rc3-omap$ git reset --hard

 

이때 주의할것은 git status 에서 untracked file 이 있으면 리셋할때 파일이 지워집니다.

untracked file 이 없도록 commit 해놓고 reset 하세요.

 

4. git pull

kdsoo@chromatix:/home/share/GIT/OMAP3430/linux-2.6.29-rc3-omap$ git pull

 

하시면 깨끗하게 최신으로 패치 됩니다.

 

5. 본인이 수정한 파일을 패치로 적용

  • 우선 패치해도 에러가 안나는지 테스트 합니다.
    • patch -p1 --dry-run < work.patch
  • patch fail 이 되지 않으면 패치 해도 됩니다.
    • patch -p1 <work.patch
  • patch fail 이 하나라도 나면 fail 난 파일의 diff 내용만 따로 파일로 보관하고 work.patch 에서 삭제합니다.
  • fail 난 파일의 diff 를 수작업으로 붙여넣어 줍니다.

 

6. 정리하면

  1. git diff > work.patch
  2. git reset --hard
  3. git pull
  4. patch -p1 --dry-run < work.patch
    1. 성공시 : patch -p1 <work.patch
    2. fail 시 : fail 되는 파일의 diff 만 따로 파일로 저장해두고 work.patch 에서 해당 파일 패치는 삭제후 다시 patch
크리에이티브 커먼즈 라이선스
Creative Commons License

Tag : , , , ,

« PREV : 1 : ... 50 : 51 : 52 : 53 : 54 : 55 : 56 : 57 : 58 : ... 692 : NEXT »