Skip to content
GwiyeomGo Tech Blog
About GwiyeomGo

Git rebase 대상 커밋과 upstream 커밋의 patch 내용이 동일한 경우 커밋을 건너뛴다

GIT, 20242 min read

배경

rebase 대상 커밋과 upstream 커밋의 patch 내용이 동일한 경우 커밋을 건너뛴다

  • branch main -> FETCH_HEAD warning: skipped previously applied commit 927650a 힌트: use --reapply-cherry-picks to include skipped commits 힌트: Disable this message with "git config advice.skippedCherryPicks false"

git cherry-pick --reapply-cherry-picks 927650a

이게 무슨 상황이지? Git이 중복된 변경 사항을 감지해서 생기는 현상

내가 뭘 하면 될까?

의도된 동작이면 무시 내 커밋이 누락되었는지 확인 git cherry -v origin/main

재현 가능?

개발하다가 순식간에 만난에러.. 일단 개발 환경에서 다시 재현할 수 없으니 github 에서 재현해보자

git init rebase-test && cd rebase-test && echo "hello" > file.txt && git add . && git commit -m "Initial"
git checkout -b feature && echo "foo" >> file.txt && git commit -am "Add foo (feature)"
git checkout main && echo "foo" >> file.txt && git commit -am "Add foo (main)"
git checkout feature
git rebase main

rebase 시 "Add foo (feature)" 커밋이 내용 중복으로 생략 (= rebase 과정에서 자동으로 drop됨)

main 브랜치에서 "foo"를 추가한 새 커밋을 만들고 다시 feature 브랜치로 돌아가 main의 변경사항 위에 feature 커밋을 얹으려 했는데 이미 동일한 내용이 있어서 feature 커밋은 생략되고, 브랜치만 main 위로 옮겨짐

Switched to branch 'feature'
warning: skipped previously applied commit bf94da6
hint: use --reapply-cherry-picks to include skipped commits
hint: Disable this message with "git config advice.skippedCherryPicks false"
Successfully rebased and updated refs/heads/feature.

결과적으로 feature 브랜치가 main과 완전히 같아진 상태가 된 것

git log --oneline --graph 확인

  • 23a2c3d (HEAD -> feature, main) Add foo (main)
  • d8f1758 Initial

참고

https://stackoverflow.com/questions/61905448/git-cherry-pick-and-then-rebase https://stackoverflow.com/questions/52789519/how-does-git-rebase-skip-the-commit-which-its-change-already-has-in-upstream

© 2025 by GwiyeomGo Tech Blog. All rights reserved.