아래의 과정을 거쳐 로컬 컴퓨터의 특정 폴더에 들어있는 코드 전부를 GitHub에 백업할 수 있다.
1. GitHub에서 repository 생성하기
- 우상단의 +를 클릭 > [New repository] > Repository 이름 입력 > (외부로 공유하고 싶지 않을 시 Private 체크) > [Create repository]
2. GitHub에서 personalized token 생성
- [Settings]>[Developers settings]>[Personal access tokens]>[Generate new token]
- Note 및 적절한 scopes (repo 등) 선택 후 [Generate token]
- 생성된 [Token] 복사
3. 로컬 컴퓨터의 폴더 내 코드를 GitHub에 업로드
- 로컬 컴퓨터의 폴더에 들어가서 마우스 오른쪽 클릭 > [Git Bash Here]
- Git Bash에서 아래의 command 입력
# 사용자 설정
$ git config --global user.name "[내 계정]"
$ git config --global user.email [이메일]
$ git config --list # 사용자 설정 확인
$ git init
$ git add .
$ git commit -m "first commit"
$ git remote add origin https://[내 계정]:[복사해 둔 토큰]@github.com/[내 계정]/[Repository 이름].git
# URL을 잘못입력한 경우 아래 명령어로 다시 입력
# git remote set-url origin https://[내 계정]:[복사해 둔 토큰]@github.com/[내 계정]/[Repository 이름].git
$ git remote # Remote repository 확인
$ git push -u origin master
# GIt token
728x90
반응형
'Computer Science > Git & GitHub' 카테고리의 다른 글
[GitHub] Gist를 활용한 코드 (Jupyter notebook) 공유 (0) | 2022.02.26 |
---|---|
[GitHub] 개발을 위한 Branch 관리 (Upstream, Origin, Local repository) (0) | 2021.03.26 |