본문 바로가기
GIT

git 폴더 remote - 리포지토리 설정하여 코드 올리기

by Rainbound-IT 2023. 8. 30.
반응형

 

 

 

일반 폴더에 프로젝트의 리포지토리를 연동하려고 한다.
예를들어 example 폴더를 A branch 와 연동하고 싶은것.

 

 

방법

git init

git remote add origin [git 주소]

git add .; git commit -m [message]

git push --set-upstream origin main

 

대략 이런식으로 진행했다.

 

 

 

에러 및 해결방안

아무것도 없는 리포지토리를 remote 하려면 다음과 같이 하면 된다.

 

git remote add origin [url or ssh]

 

error: remote origin already exists.

이럴 땐 remote origin을 삭제

 

git remote remove origin

 

 

 

git push -u origin master

error: src refspec master does not match any

 

이런 경우는 위에서 나왔듯이

git push --set-upstream origin main

하면 된다.  요즘엔 master보단 main을 많이 사용해서 remote branch 삭제하고 다시 등록을 하던가 해야한다.

 

 

 

 

이게 귀찮아서 폴더 만들어서 clone하는게 더 편한것 같기도하다.

 

 

Reference

https://0ver-grow.tistory.com/1102

 

[해결방법] error: src refspec master does not match any

상황 : git push origin master 입력하니 error: src refspec master does not match any 발생 원인 : 깃허브에서 pull 없이 push할 경우 기존 내용 삭제 문제가 생길 수 있기 때문. 해결 방법 : git init git add . git commit -m "

0ver-grow.tistory.com

끝!

반응형

'GIT' 카테고리의 다른 글

[VScode]gitlens 설치 및 설정, 팁  (0) 2023.07.19
스프링 컨테이너  (0) 2023.03.18
git 저장소 name, email 설정  (0) 2022.11.29
GIT 브랜치 전략  (0) 2022.11.02
프로그래밍 언어 16선  (0) 2022.08.18

댓글