Wecode -기업협업 인턴 (부트캠프)/기업협업 인턴(프로젝트)

기업협업 2번째 프로젝트: 깃허브 에러 해결

JBS 12 2023. 11. 7. 15:18
 
 
➜ short-url git:(develop) git push -u origin dev error: src refspec dev does not match any error: failed to push some refs to 'https://github.com/ [       ] .git'

origin https://github.com/ [       ] .git (push) ➜ short-url git:(develop) ✗ git push -u origin main error: src refspec main does not match any error: failed to push some refs to https://github.com/ [       ] .git➜ short-url git:(develop) ✗ git push -u origin dev error: src refspec dev does not match any error: failed to push some refs to https://github.com/ [       ] .git➜ short-url git:(develop) ✗

 

git flow init을 하면서 git dev 가 생성되었어

 

 


 

해결하려는 문제는 Git 브랜치가 로컬에서 생성되지 않았거나 커밋되지 않았을 때 발생하는 문제로 보입니다.

현재 로컬에서 develop 브랜치가 생성되어 있고 커밋이 있는 것으로 보이므로 브랜치 자체에 문제는 없어 보입니다.

그러나 "git push -u origin dev" 명령이 여전히 "error: src refspec dev does not match any" 오류를 반환한다면, 원격 저장소와 로컬 저장소 간에 브랜치 이름이 일치하지 않을 수 있습니다.

원격 저장소와 로컬 저장소 간의 브랜치 이름을 확인하고 다음과 같이 git push 명령을 실행하세요:


git push -u origin develop:dev
위 명령은 로컬 develop 브랜치를 원격 dev 브랜치로 푸시합니다.

또한 "git push -u origin main" 명령을 실행하려는 경우, main 브랜치가 로컬에 아직 생성되지 않았다는 것을 나타내므로 main 브랜치를 먼저 로컬에서 생성하고 커밋한 다음 git push -u origin main 명령을 실행하세요.


 

 

보통은 브랜치 이동을 하면, 작성한 파일이 사라지거나 없어지는데, 그렇지 않은 이유는 commit을 안했기 때문이니

-- > openai가 헛소리해서 

내가 직접 해보았는데, git add, git commit을 하지 않아서 그런 게 맞았다. 

그 후 dev 브랜치 이동해보니, 내가 기능 api 브랜치에서 작성한 코드는 사라진다 

 

commit전에는 다 반영됐었다.