코더
깃허브 관리 / 발생한 문제점 본문
# 1. 작업 중인 내용 임시 커밋
git add .
git commit -m "wip: 작업 중"
# 2. 다른 사람이 develop에 최신 코드를 올렸다면
git switch develop
git pull origin develop
# 3. 다시 내 작업 브랜치로
git switch feature/payment
# 4. 최신 develop을 내 브랜치에 반영
git fetch origin
git merge origin/develop
# 5. 이어서 작업
해결 방법 2
git stash
git checkout develop
git pull origin develop
git checkout feature/payment
git merge develop
git stash pop
을 하면 된다. 당연하게 내가 작업한 내용을 최신화한 develop 내용에 가져와서 수정하는게 더 에러가 날 확률이 적다 .
해셜방법 3
git stash
git fetch origin
git checkout feature/payment
git merge origin/develop
git stash pop
//GitHub의 최신 develop 정보를 내 로컬의 origin/develop에 갱신 => git fetch origin
----------------------------------------------------------------------------------------------------------------------
의문점
그렇다면 깃허브 충돌이 일어나지 않으면??
그러니까 만약에 feature/auth 작업하다 develop으로 git switch를 한다면??
===>
그럴경우 충돌이 일어나지 않으면 feature/auth의 변경된 내용이 develop에 옮겨지게 된다.
즉, 내 변경내용이 어찌되었던 영향을 미치지 않고 옮겨지게 하고 싶다면
git stash나 git commit을 하고 branch를 이동하는게 바람직하다.
----------------------------------------------------------------------------------------------------------------------
1. 발생한 문제점
문제점 :
현재 feature/match에서 작업중이지만 docker-compose.yml에서 변경한 내용만 feature/auth 브랜치에서 push
해야하는 상황이 벌어졌다. git switch를 해보았지만 역시나 match 관련한 부분 yml 관련한 부분이 기존 코드와 달라 switch가 안되는 현상이 벌어졌다.
해결방법
git stash push -m "docker-compose.yml 수정" -- docker-compose.yml
git stash push -m "match 작업"
git switch feature/auth
git stash list
git stash pop stash@{1}
(여기에서 commit & push를 해준다.)
git switch feature/match
git stash pop
위와 같은 방법으로 해결해주었다.
어차피 fearue/match로 돌아온 이상 match에 대한 stash밖에 남아있지 않음으로
git stash pop을 실행해주면 된다.
결과 :

2. 문제점
이번에 발생한 문제점은
stash pop을 하고 commit/push를 했으니까 docker-compose.yml 내용은 이미 pull request로 들어가고
feature/match 브랜치로 다시 돌아올 때에는 docker-compose.yml 내용이 사라진것이었다. (당연하다 이미 stash로 임시저장을 한것을 다른 브랜치에 꺼내서 사용했으니까 다시 feature/match 브랜치로 돌아왔을 때는 docker-compose.yml변경한 내용이 반영안된다.)
해결방법 :
git stash
git fetch origin
git merge origin/develop
git stash pop
을 실행해준다.

----------------------------------------------------------------------------------------------------------------------
전체 해결과정
git stash push -m "docker-compose.yml 수정" -- docker-compose.yml
git stash push -m "match 작업"
git switch feature/auth
git stash list
git stash pop stash@{1}
(여기에서 commit & push를 해준다.)
git switch feature/match
git stash pop
// 현재 브랜치는 feature/match에 있어야 함
git stash
git fetch origin
git merge origin/develop
git stash pop
'최종 프로젝트' 카테고리의 다른 글
| docker 재정리 (0) | 2026.09.03 |
|---|---|
| (최종 프로젝트) 구글 recaptcha (0) | 2026.08.13 |
| (최종 프로젝트)Oauth2.0 정리 (0) | 2026.08.13 |
