상세 컨텐츠

본문 제목

Git - Github Repository와 Local Directory 연동

Git & Github/Git

by KDLiam 2023. 8. 22. 23:29

본문

전제 조건

1. Git 설치 & 초기 Setting

2. Local -> Directory 생성

3. Github -> Repository 생성

 

* [RESULT] 는 해당 명령을 작성했을 때 나오는 결과입니다. 직접 작성하는 것이 아닙니다. *

 

과정

 

[ Git Bash ] 연동할 Directory에서

 

1. 계정 연동

$ git config --global user.name {yourName} 
$ git config --global user.email {yourEmail}

(확인)

$ git config user.name

[ Result ] -> yourName

$ git config user.email

[ Result ] yourEmail

 

2. 폴더 초기화

$ git init

[ RESULT ] Initialized empty Git repository in [Your Directory Address]/.git/

$ git add .

$ git commit -m "message"

 

3. Github 연동

$ git remote add origin [yourGithubAddress]

ex) git remote add origin https://github.com/yourName/yourRepositoryName.git 

[ RESULT ] 아무 것도 출력되지 않습니다.

(확인)

$ git remote -v

 

4. Github Upload

$ git push --set-upstream origin main

(첫 push에만 이렇게 작성하고, 이후에는 '$ git push' 만 작성하시면 됩니다.

 

 

 


fatal: protocol '?[200~https' is not supported

 

해당 문제가 발생한다면, github의 주소를 웹상에서 복사하고 Git Bash에 붙여넣기 함으로써

 

주소 앞에 ' ^[[200~ ' 이라는 문자가 붙여져서 생기는 문제였다.

 

$ git remote remove origin

$ git remote add origin https://github.com/...

 

이 문자열을 삭제하고 다시 하면 해결된다

 

 

 

 

 

* 게시글에 오류가 있거나, 보충이 필요한 부분은 댓글에 작성해주시면 정말 감사하겠습니다!