-
dev 로 merge 했어야 했는데 main 으로 머지했을때의 대처법git & Github 2023. 5. 23. 21:16
문제상황 : dev로 merge 했어야 했는데 main 으로 merge 해버렸다. 어떻게 대처해야할까?
1. 먼저 merge 한 pr 에 들어가 revert 를 통해 머지했던 커밋들을 분리시켜 새 pr 을 생성한다.
2. vscode 로 넘어가 main 을 pull 땡긴 후 reset 을 진행한다. (내가 원하는 커밋 위치로 돌아가는 행위)
- git reset --hard [이동하고 싶은 시점의 커밋 해시 값]
- git push -f origin main 강제로 밀어버린다.
- 정말 위험하니 꼭 확인하도록 이전 커밋들 죄다 날려버림 revert 했는지 확인꼭 하세요!
'git & Github' 카테고리의 다른 글
Organization을 만들고 팀원들이 git push 했을 때 access 접근권한이 없다고 오류가 나면 403 해결책 (0) 2023.03.15 깃허브를 통해 React를 배포해보자 (0) 2023.03.10 git revert : 잘못 merge 한 pull request 를 분리하여 다시 커밋한다. (0) 2023.02.04