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.

브랜치를 메인에 병합

다음으로 방금 생성한 브랜치(즉, issue1)를 main에 대한 커밋과 함께 병합하겠습니다.

커밋을 메인 브랜치로 병합하려면 먼저 메인 브랜치로 전환해야 합니다.

$ git checkout main
Switched to branch 'main'

병합하기 전에 myfile.txt 파일을 열고 파일 내용을 확인합니다. 다음 내용이 표시됩니다.

Anyone can learn Git with this tutorial and Backlog

보시다시피 이전 단계에서 만든 issue1에 추가된 변경 사항은 메인 브랜치의 myfile.txt 파일에 포함되지 않습니다.

Git merge 명령을 사용하면 지정된 커밋이 활성 브랜치와 병합됩니다. 다음 명령을 사용하여 이제 병합할 수 있습니다.

$ git merge issue1
Updating 1257027..b2b23c4
Fast-forward
myfile.txt |    1 +
1 files changed, 1 insertions(+), 0 deletions(-)

메인 브랜치의 위치는 이제 "issue1"의 위치로 이동하여 fast-forward 병합을 실행합니다.

Current history

마지막으로 myfile.txt 파일의 내용을 확인하겠습니다. myfile.txt를 열면 issue1 브랜치에 커밋한 새 줄이 이제 메인 브랜치에 있는 것을 볼 수 있습니다.

Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life