Developer J

[Visual Studio Code] Github에 코드 올리는 방법 본문

개발자 되기 part1/개발환경

[Visual Studio Code] Github에 코드 올리는 방법

Developer J 2020. 8. 24. 13:19
반응형

1. Git 설치하기

운영체제에 맞게 설치해 줍니다.

https://www.git-scm.com/downloads

 

Git - Downloads

Downloads Mac OS X Windows Linux/Unix Older releases are available and the Git source repository is on GitHub. GUI Clients Git comes with built-in GUI tools (git-gui, gitk), but there are several third-party tools for users looking for a platform-specific

www.git-scm.com

2. Github에 저장하고자 하는 repository를 생성합니다.

github repository 생성

repository name에 원하는 이름을 작성하고 저장소를 생성해 줍니다.

 

3. repository의 주소를 복사해 줍니다.

github repository 주소 복사

4. repository를 초기화

vscode git repository

 로컬의 repository가 초기화됩니다.

 

5. Github에 push를 하기 위해서는 먼저 로컬 repository에 commit을 해줍니다.

vscode commit

이상태로 체크표시(commit버튼)를 누르면 모든 변경사항이 저장됩니다.

변경사항이 있는 파일의 옆에 있는 +를 선택 시 아래와 같이 스테이징 된 변경사항이 선택됩니다.

스테이징된 변경사항이 선택되면 선택된 변경사항만 commit 되게 됩니다.

vscode commit

6. View > Terminal을 선택해 터미널 창을 열어줍니다.

아래의 명령어를 통해 원격 repository의 저장 위치를 설정해 줍니다.

git remote add origin https://github.com/*******/test1.git

만약 fatal: remote origin already exists. 이라는 오류메시지가 뜬다면 git remote rm origin을 입력해주고 다시 주소를 add해주면 됩니다.

7. 터미널에 git pull origin master --allow-unrelated-histories 입력

깃허브에 존재하는 내용과 로컬 repository의 차이를 없애서 push작업에서 발생할 오류를 방지합니다.

8. 터미널에 git push -u origin master 입력

처음 이용 시 깃허브 로그인이 필요합니다.

Github에 코드를 업로드해 줍니다. (commit이 진행된 파일만 업로드됩니다.)

반응형