git 과 github의 차이
git은 버전관리 시스템이자 소프트웨어여서 저의 현재 pc 에 설치되어있습니다.
github 는 git에서 올린 코드, 흔적을 보관하는 저장소이자, 웹사이트 입니다.
git push 과정중 충돌하였을 때
C:\APM\Apache24\htdocs\border>git push origin border
To https://github.com/Andante23/phpStudy.git
! [rejected] border -> border (fetch first)
error: failed to push some refs to 'https://github.com/Andante23/phpStudy.git'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

걱정하지마십쇼. 저는 이걸 파파고에 번역을 해보았습니다.
힌트: 리모컨에 포함되지 않은 작업이 포함되어 있어 업데이트가 거부되었습니다
힌트: 로컬에 있습니다. 이는 일반적으로 다른 리포지토리가 다음을 푸시하기 때문에 발생합니다
힌트: 동일한 참조. 원격 변경 사항을 통합하려면 다음을 사용합니다
힌트: 다시 밀기 전에 '기트 당기기'.
힌트: 자세한 내용은 '기트 푸시 --도움말'의 '빠른 전달에 관한 메모'를 참조하세요.
이말은 즉 원격 저장소인 github에서 변경된 내용이 있으니 이걸 해결하라는 것입니다. 그래서 저는 다음 마지막에서
2번째줄에 있는 기트 당기기 즉 git pull을 하여 원격 저장소에서 가져와서 병합합니다.
git pull origin [브랜치명] // 이렇게 사용해주세요
C:\APM\Apache24\htdocs\border>git pull origin border
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (4/4), 1.77 KiB | 121.00 KiB/s, done.
From https://github.com/Andante23/phpStudy
* branch border -> FETCH_HEAD
eb52a64..1c63201 border -> origin/border
Merge made by the 'ort' strategy.
여기서 끝이 아니죠 . git push를 해주어야합니다.
C:\APM\Apache24\htdocs\border>git push origin border
Enumerating objects: 15, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 8 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 924 bytes | 462.00 KiB/s, done.
Total 7 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
To https://github.com/Andante23/phpStudy.git
1c63201..a673452 border -> border
원격 브랜치 가져오고 싶을 때
git branch를 생성하는 명령어입니다.
git branch [새 브랜치명]
다음은 branch 를 조회하는 명령어입니다.
C:\APM\Apache24\htdocs\border>git branch
* border
calc
# 이렇게 했는데 이미 이름이 변경된 calc가 계속 있네요
그래서 저는 calc 를 찾아보니 master로 변해있는걸 github에서 알았습니다.
https://cjh5414.github.io/get-git-remote-branch/#google_vignette
Git remote branch 가져오기
Jihun's Development Blog
cjh5414.github.io
여기를 통해 해결 할 수 있었습니다.
1. 먼저 깃 원격 저장소 리스트를 가져옵니다. = git branch -r
C:\APM\Apache24\htdocs\border>git branch -r
origin/border
origin/master
2. 현재 브랜치를 확인합니다. = git branch
C:\APM\Apache24\htdocs\border>git branch
* border
calc
3. chechout -t 명령어를 이용해서 원격 브랜치를 가져옵니다.
C:\APM\Apache24\htdocs\border>git checkout -t origin/master
branch 'master' set up to track 'origin/master'.
Switched to a new branch 'master'
4. 새 브랜치인 master가 왔다는 것입니다. 다시 git branch 를 하면 지워야 되는 브랜치인 calc가 있네요
C:\APM\Apache24\htdocs\border>git branch
border
calc
* master
5. 지워줍시다. git branch -d calc
C:\APM\Apache24\htdocs\border>git branch -d calc
Deleted branch calc (was be81df9).
'개발 > git' 카테고리의 다른 글
git을 적용하면서 발생했던 오류 해결하기 (0) | 2025.02.28 |
---|