Git Merge

m_ngyeong·2023년 7월 21일
0

Concept

목록 보기
3/7
post-thumbnail

Git Merge

merge란 git branch를 다른 branch로 합치는 과정을 말하며, 기본 단위는 branch이다.
git merge 명령어로는 commit 단위로 합치기가 불가능하다.

brach 생성 후 pull request하기

  1. 로컬 저장소에서 작업할 branch를 생성 후 해당 branch로 이동
# branch 생성
$ git branch [브랜치이름]

# branch 이동
$ git checkout [브랜치이름]
  1. branch에서 작업을 한 후 수행한 작업을 git에 올림
# (작업 중인 branch 안에서 명령어 실행)
$ git add .
$ git commit -m "~~"

# 원격 저장소에 해당 branch가 이미 존재할 때
$ git push 
# 원격 저장소에 해당 branch가 없을 때
$ git push origin [브랜치이름]
  1. 로컬 master branch로 이동 후, 원격 저장소의 master 변경사항을 pull(master의 내용을 제일 최신으로 업데이트)
# (작업 중인 branch 안에서 명령어 실행)
$ git checkout main

# (master branch 안에서 명령어 실행)
# origin master 생략 가능
$ git pull origin master
  1. 작업한 branch로 이동 후, 로컬의 master 내용을 해당 branch에 merge
# (작업 중인 브랜치 안에서 명령어 실행)
$ git merge master
$ git push
  1. github 홈페이지의 repository로 이동 후, pull request 요청

참고문서,
https://developer-eun-diary.tistory.com/42

profile
ʚȉɞ

0개의 댓글