728x90
해결 방법 1. 강제로 덮어 씌우기
1.1. 원격 저장소(origin)의 내용을 로컬 저장소(new_branch)로 가져와 덮어쓰기(강제 pull)
1. 내용을 덮을 브랜치로 이동한다.
git switch new_branch
2. 원격 저장소 내용을 덮어씌운다.
git reset --hard origin/new_branch
1-2. 로컬 저장소의 내용을 원격 저장소에 가져와 덮어쓰기(강제 push)
git push origin +내용을 덮을 원격 저장소 이름
// git push origin +main
해결 방법 2. 변경된 내용만 가져와 병합하기
1. 원격 저장소에서 변경 내용을 fetch
git fetch 원격 저장소 이름
// git fetch origin
2. 변경 내용을 로컬 브랜치에 병합
git merge 원격 저장소 이름/로컬 브랜치 이름
// git merge origin/new_branch
[참고]
https://docs.github.com/ko/get-started/using-git/getting-changes-from-a-remote-repository
https://shortcuts.tistory.com/19
728x90
'Git' 카테고리의 다른 글
[Git]repository에서 필요한 하위 디렉토리만 clone(git 2.25 이후) (0) | 2024.03.17 |
---|---|
[Git]Github으로 협업(clone, pr, merge, 충돌 해결) (0) | 2024.03.06 |
[GitHub][해결]화살표 폴더 (0) | 2023.08.24 |
[Git][해결]remote: Invalid username or password. (0) | 2023.07.14 |
[Git]Repository 이동(잔디 살리기) (0) | 2022.10.24 |