Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git 사용 방법
  6. Git에서 기록을 관리하는 방법
  7. 커밋을 다른 브랜치로 복사
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

커밋을 다른 브랜치로 복사

이전에 다운로드한 git-tutorial/tutorial4 디렉터리로 이동합니다.

이 저장소의 기록을 검토하면 다음과 같이 표시됩니다.

Current history

동일한 저장소의 다른 브랜치에 대한 커밋의 복사본인 메인 브랜치에 새 커밋을 만들 것입니다. 이 경우 "append description of the commit command"라는 메시지와 함께 커밋을 복사해 봅시다.

메인 브랜치로 전환합니다. git cherry-pick 명령을 사용하고 "append description of the commit 명령"에 대한 커밋 해시를 지정합니다.

커밋 해시 99daed2는 로컬 저장소에 따라 다를 수 있습니다. 해당 브랜치에서 git log 명령을 실행하여 커밋 해시를 얻을 수 있습니다. 로컬 저장소의 커밋 해시를 찾아서 대신 사용하십시오.

$ git checkout main
  Switched to branch 'main'
$ git cherry-pick 99daed2
  error: could not apply 99daed2... commit
  hint: after resolving the conflicts, mark the corrected paths
  hint: with 'git add <paths>' or 'git rm <paths>'
  hint: and commit the result with 'git commit'

위에서 볼 수 있듯이 충돌이 발생했습니다. 수동으로 해결하고 변경 사항 커밋을 진행합니다.

$ git add sample.txt
$ git commit

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life