[Error|git] no tracking information for the current branch

NX2411·2024년 12월 12일

Error

목록 보기
1/2

Git init & pull...

진짜 깃허브 할때마다 까먹어서 미쳐버리겠는 사람임
팀플할 일이 없고 계속 혼자 작업하니까 로컬에서 파일관리하고...
결국에는 파일 다 깃에 올려야하긴 하니까 간간히 깃 접속하면 그냥 죄다 까먹음

$ git init 
Initialized empty Git repository in D:/GUIdetection_featureextraction_model/.git/

$ git remote add origin https://github.com/NX2411/GUI-detection-model.git

$ git remote -v
origin  https://github.com/NX2411/GUI-detection-model.git (fetch)
origin  https://github.com/NX2411/GUI-detection-model.git (push)

여까지 아무 문제 없었고... pull 땡겨와야되니까 pull 했는데...

$ git pull
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (4/4), 4.87 KiB | 383.00 KiB/s, done.
From https://github.com/NX2411/GUI-detection-model
 * [new branch]      main       -> origin/main
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

앗쉬 보니까 로컬 브랜치에 추적 정보 없다고 뜨는데...
원격 브랜치랑 지금 로컬 브랜치가 연결이 안되어 있음
왜그런가 봤더니 원격 브랜치가 origin/main으로 이미 initial commit이 되어있음

해결책

이자식 원격 브랜치 로컬로 가져와서 다시 연결해줘야함
초기 커밋이 있기때문에, 병합 작업하는게 제일 좋을듯 싶음

첫번째 해결책

$ git pull origin main

From https://github.com/NX2411/GUI-detection-model
 * branch            main       -> FETCH_HEAD

원격 브랜치 (origin/main) 로컬로 가져오고 병합작업 시도
이걸로 가뿐하게 성공함..

두번째 해결책

git branch --set-upstream-to=origin/main

만약 저걸로도 안된다고 하면 현재 로컬 브랜치가 원격 브랜치를 추적하도록 설정해주어야 함
이렇게 하고, git pull 명령어만 입력하면 원격의 main 브랜치와 바로 동기화 가능

profile
개발하고싶은연구원

0개의 댓글