본문 바로가기
Programming/Git

squash - git commit을 깔끔하게

by Chan_찬 2020. 6. 22.
728x90

squash

push 전에 깔끔하게 하나의 커밋으로 올리고 싶을 때 사용

local master branch 최신화

# pull local master
$ git checkout master
$ git pull origin master
# rebase
$ git rebase -i master mybranch

squash

pick last commit
pick --
pick --
pick --
pick first commit

처음 pick 만 두고 나머지는 s (squash)로 수정한다

pick last commit
s --
s --
s --
s first commit

conflict 발생

conflict 가 해결될 때까지 1,2,3을 반복

# conflict 나는 부분 수정      # 1
$ git add files             # 2
$ git rebase --continue     # 3

마지막 commit message 작성

git push

conflict를 해결한 경우, git에서 거부!

$ git push -f origin mybranch
728x90
728x90

'Programming > Git' 카테고리의 다른 글

git 특정 commit 삭제 - rebase  (0) 2023.04.13
git push 전에 할일 - PR 시 conflict  (1) 2023.01.25
git force push  (0) 2020.06.18
git stash - 작업 임시 저장  (0) 2020.06.16
git pull overwrite  (0) 2020.06.10
Buy me a coffeeBuy me a coffee

댓글