본문 바로가기
프로그래머/프로그래밍

Visual Studio Code 와 Github 연동하는 법

by plog 2022. 12. 14.

1) 사전 준비

Visual Studio Code 설치 

 

Visual Studio Code - Code Editing. Redefined

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.  Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.

code.visualstudio.com

 

Github 가입 

 

GitHub: Let’s build from here

GitHub is where over 94 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and feat...

github.com

 

2) Github 에서 repository 생성 

3) repository 주소 저장 

4) VSCode 에서 Test 폴더 생성 >> Open folder >> 간단한 test.py 파일 생성 

 

5) Initial Repository 

6) Remote Setting

상단 메뉴: Terminal >> New Terminal 

커멘드 창에서 git remote add origin "위에서 복사한 repository 주소"

설정상태 확인 git remote -v

 

7) commit

+ 버튼 클릭 >> Staged Changes 파일 이동 시킨후 >>  commit  

 

8) push 

publish branch 버튼 또는 push

명령어 : git push origin master

 

9) 확인 

github 확인 

 

연동 오류 (오류 처리)

1) Make sure you configure your 'user.name' and 'user.email' in git 

사용자 정보를 설정이 안된 경우.

git config --global user.name "test"

git config --global user.email "test@test.com"

 

2) Can't push refs to remote. Run 'Pull' first to integrate your changes.

로컬 Repository의 변경을 적용하기 전에 이미 원격 Repository에서 변경이 발생한 것으로 Merge 가 필요한 상태

git pull origin master

 

3) Refusing to merge unrelated histories.

로컬과 원격이 동일한 Base 에서 시작하지 않았기 때문에 Merge 중에 연관되지 않은 기록이 존재한다는 것으로 아래의 명령을 통해서 이런 내용들을 모두 수용하는 것으로 처리를 하면 된다.

git pull origin master --allow-unrelated-histories

 

4) There is no tracking information for the current branch

일반적으로 로컬 Repository는 기본적으로 master로 지정되므로 이를 사용하면 된다. 만일 다른 브랜치를 클론 받은 상태라면 해당 브랜치를 지정하면 된다.

git branch --set-upstream-to=origin/<브랜치명>

 

 

 

Visual Studio Code 유용한 단축키

VS Code 필수 단축키 Alt + Shift + A 블록 지정후 전체 주석. Ctrl + Shift + p Command Palette 오픈 Ctrl + Tab 열려 있는 파일 사이 이동. Ctrl + / 줄 단위 주석 F11 전체 화면. 디버그 모드에서 함수 내부로 이동.

plogds.tistory.com

댓글