Git

[Git] local에서 작업하던 프로젝트를 Git repository에 연결

지니지니하지니 2023. 7. 21. 14:10

기존에 작업하던 프로젝트를 github에 올리고 싶다면 아래의 방법대로 진행해주세요.

 

1. gitgub에 빈 repository 생성

github 에서 새로운 repository를 생성해줍니다.( README 파일은 생성하지 말아주세요)

 

2. 터미널에서 local 에 있는 프로젝트의 루트로 이동

cd testProejct

3. git 초기화

git init

4. 스테이지에 모든 파일 업로드

git add .

5. 커밋

git commit -m "원하는 커밋메세지"

6. github repository와 local 연결

git reomote add origin 레파지토리주소(https 주소)

7. github에서 개인 엑세스 토큰 생성 또는 기존토큰 확인

생성 : https://github.com/settings/tokens/new

remote: Support for password authentication was removed ....  (비밀번호 인증지원이 제거됐기 때문에 개인토큰으로 로그인해야합니다.)

github 프로필 클릭 -> Settings -> 왼쪽 메뉴 맨 하단의 <>Developer Settings -> Personal access tokens -> Generate new token(classic) -> 필요한 권한 선택(다 선택해도 됩니다..) 후 Generate token

생성완료 페이지에 나타난 토큰을 복사! (이게 비밀번호가 될겁니다)

 

기존 키체인 삭제 후 터미널에서 user 정보 입력

git config --global user.name 깃헙계정이름
git config --global user.email 깃헙계정

ex)
git config --global user.name Tony
git config --global user.email abc@naver.com

8. 원격저장소에 push

git push -u origin main

9. github 계정 정보 입력

Username for 'https://github.com':본인계정이름

ex) Username for 'https://github.com':Tony

Password for 'https://Tony@github.com':만들어둔 개인 엑세스 토큰

 

 

해당 과정대로 진행하면 성공적으로 원격저장소에 로컬에서 작업한 프로젝트가 올라가게 됩니다.