작업 경로:
E:\sources\terraform_code
원격:origin = github.com:jsh0911/terraform_code.git
기본 브랜치:main
git push origin +main → src refspec main does not match any
main에 커밋이 하나도 없는(unborn) 상태.git pull → There is no tracking information for the current branch
main이 어떤 원격 브랜치를 추적할지(업스트림) 미설정.git pull origin main
git branch -u origin/main
git pull/git push만으로 동작.git branch -vv
# 예) * main 4961c81 [origin/main] 20250930
[origin/main] 표기가 보이면 업스트림 OK.git branch -r
# origin/HEAD -> origin/main ← 원격의 '기본 브랜치'를 가리키는 심볼릭 포인터
# origin/main ← 실제 원격 추적 브랜치
# 최신 반영
git pull --rebase
# 변경사항 커밋
git add .
git commit -m "메시지"
# 업로드
git push
git config --global pull.rebase true # pull 시 기본 rebase
git config --global push.default simple
git config --global fetch.prune true # fetch 시 불필요한 원격 브랜치 정리
로컬에 수정/새 파일이 있어서 pull에 방해될 때:
git stash -u # 변경 임시 보관
git fetch origin --prune
git checkout -B main origin/main
git branch -u origin/main
git stash pop # 보관분 적용(충돌 시 해결 후 add/rebase --continue)
fatal: the requested upstream branch 'origin/main' does not exist
git branch -r 로 원격 브랜치 이름 확인(예: master면 origin/master로 설정).src refspec main does not match any
detached HEAD 상태로 내려왔을 때
git switch -c main --track origin/main