Step it up now

내 브랜치에서 작업 중에 push 된 부분 pull하기 본문

프로젝트/파이널

내 브랜치에서 작업 중에 push 된 부분 pull하기

케잉 2024. 2. 22. 21:52

브랜치 받아서 작업도중에 누군가 업데이트를 했다고 한다 

난 이 업데이트를 받아야만 했다

 

 

1. 마스터로 이동 

git checkout master

2. 현재 작업중인 변경사항 보존하기 위한 새로운 브랜치 생성

git branch new-branch-to-save-current-commits

3.원격저장소의 업데이트 된 것 로컬로 가져오기 

git fetch --all

4.로컬 마스터 브랜치와 원격 마스터 브랜치 동일하게 재설정 

이를 통해 로컬브랜치를 원격의 최신 상태로 강제 업데이트 한다

git reset --hard origin/master

 

 

 


 

 

커밋이 성공했으나 깃허브에 내가 커밋한 내용이 보이지 않는다 

 

 

올바른 브랜치로 푸시하지 않았을 수 있습니다: 로컬에서 작업하고 있는 브랜치와 푸시하려는 브랜치가 일치하지 않으면 변경 사항이 원격 저장소에 반영되지 않습니다. 예를 들어, 로컬에서 master 브랜치에서 작업하고 있지만 원격 저장소에는 다른 브랜치로 푸시하려고 했을 경우 해당 커밋은 깃허브에 표시되지 않을 것입니다.

 

 

 

그러나 내 로컬 브랜치로 이동이 안된다 

 

 

 

 
C:\final\project_vet (master -> origin) λ git checkout -b [0222kim]
 
fatal: '[0222kim]' is not a valid branch name C:\final\project_vet (master -> origin) λ git switch 0222kim error: Your local changes to the following files would be overwritten by checkout: src/main/resources/application.yml Please commit your changes or stash them before you switch branches. Aborting

 

 

에러 메시지를 보면, '0222kim'이라는 브랜치는 있는 것으로 보이지만, 현재 작업 중인 파일에 로컬 변경 사항이 있어서 브랜치를 변경할 수 없다는 것을 나타냅니다. '0222kim' 브랜치로 전환하려는 시도에서 오류가 발생한 것입니다.

  1. 변경한 내용을 커밋하거나 stash하여 임시로 저장하세요 

변경한 내용을 커밋할 경우:

git add .
git commit -m "Committing changes before switching branches"

 

2. 변경한 내용을 stash할 경우:

git stash

 

그리고나서

git switch 0222kim을 하라 

 

 


 
 
 
C:\final\project_vet (develop -> origin) λ git merge 0222kim
 
error: Your local changes to the following files would be overwritten by merge: gradlew Please commit your changes or stash them before you merge. Aborting error: Your local changes to the following files would be overwritten by merge: gradlew Please commit your changes or stash them before you merge. Aborting Index was not unstashed. Merge with strategy ort failed. C:\final\project_vet (develop -> origin) λ git add . C:\final\project_vet (develop -> origin) λ git commit -m "[다시2]" [develop 0760fee] [다시2] 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 gradlew C:\final\project_vet (develop -> origin) λ git checkout develop Already on 'develop' Your branch is ahead of 'origin/develop' by 1 commit. (use "git push" to publish your local commits) C:\final\project_vet (develop -> origin) λ git pull origin develop From https://github.com/Dakoo21/project_vet * branch develop -> FETCH_HEAD Already up to date. C:\final\project_vet (develop -> origin) λ git merge 0222kim warning: Cannot merge binary files: .gradle/8.5/executionHistory/executionHistory.bin (HEAD vs. 0222kim) Auto-merging .gradle/8.5/executionHistory/executionHistory.bin CONFLICT (content): Merge conflict in .gradle/8.5/executionHistory/executionHistory.bin warning: Cannot merge binary files: .gradle/8.5/executionHistory/executionHistory.lock (HEAD vs. 0222kim) Auto-merging .gradle/8.5/executionHistory/executionHistory.lock CONFLICT (content): Merge conflict in .gradle/8.5/executionHistory/executionHistory.lock warning: Cannot merge binary files: .gradle/8.5/fileHashes/fileHashes.bin (HEAD vs. 0222kim) Auto-merging .gradle/8.5/fileHashes/fileHashes.bin CONFLICT (content): Merge conflict in .gradle/8.5/fileHashes/fileHashes.bin warning: Cannot merge binary files: .gradle/8.5/fileHashes/fileHashes.lock (HEAD vs. 0222kim) Auto-merging .gradle/8.5/fileHashes/fileHashes.lock CONFLICT (content): Merge conflict in .gradle/8.5/fileHashes/fileHashes.lock warning: Cannot merge binary files: .gradle/8.5/fileHashes/resourceHashesCache.bin (HEAD vs. 0222kim) Auto-merging .gradle/8.5/fileHashes/resourceHashesCache.bin CONFLICT (content): Merge conflict in .gradle/8.5/fileHashes/resourceHashesCache.bin warning: Cannot merge binary files: .gradle/buildOutputCleanup/buildOutputCleanup.lock (HEAD vs. 0222kim) Auto-merging .gradle/buildOutputCleanup/buildOutputCleanup.lock CONFLICT (content): Merge conflict in .gradle/buildOutputCleanup/buildOutputCleanup.lock warning: Cannot merge binary files: .gradle/buildOutputCleanup/outputFiles.bin (HEAD vs. 0222kim) Auto-merging .gradle/buildOutputCleanup/outputFiles.bin CONFLICT (content): Merge conflict in .gradle/buildOutputCleanup/outputFiles.bin warning: Cannot merge binary files: .gradle/file-system.probe (HEAD vs. 0222kim) Auto-merging .gradle/file-system.probe CONFLICT (content): Merge conflict in .gradle/file-system.probe warning: Cannot merge binary files: build/classes/java/main/com/example/vet/controller/work/Booking_Controller.class (HEAD vs. 0222kim) Auto-merging build/classes/java/main/com/example/vet/controller/work/Booking_Controller.class CONFLICT (content): Merge conflict in build/classes/java/main/com/example/vet/controller/work/Booking_Controller.class CONFLICT (modify/delete): build/tmp/bootWar/MANIFEST.MF deleted in HEAD and modified in 0222kim. Version 0222kim of build/tmp/bootWar/MANIFEST.MF left in tree. CONFLICT (modify/delete): build/tmp/compileJava/previous-compilation-data.bin deleted in HEAD and modified in 0222kim. Version 0222kim of build/tmp/compileJava/previous-compilation-data.bin left in tree. Auto-merging src/main/java/com/example/vet/controller/work/Stock_Controller.java CONFLICT (content): Merge conflict in src/main/java/com/example/vet/controller/work/Stock_Controller.java Auto-merging src/main/java/com/example/vet/service/work/Stock_Service.java CONFLICT (content): Merge conflict in src/main/java/com/example/vet/service/work/Stock_Service.java Auto-merging src/main/resources/application.yml Automatic merge failed; fix conflicts and then commit the result.

 

 

 

허 ㅋㅋ 충돌 

 

 

<<<<<<< HEAD
// 현재 브랜치(HEAD)의 내용
=======
// 병합하려는 브랜치의 내용
>>>>>>> branch_name

 

 

인텔리제이 - git - resolve conflict 가서 

어떤것을 accept 할 건지 선택하면 된다  

 

 

 

git add .
git commit -m "메시지 내용"

 

 

됐다