카테고리 없음

github에 데이터를 관리하는 방법(git bash사용)

다만사 2023. 4. 15. 15:40

git 설치

git for windows

 

git bash를 실행

 

사용자 폴더에 .ssh폴더 작성

사용자 폴더에서 

ssh-keygen.exe 실행

 

비번작성(passphrase) --> 잊어버리지 않게 기억해둠

 

.ssh폴더에서 id_rsa.pub파일을 메모장을 열어서 모든 내용을 

github 계정그림 -> Settings -> SSH and GPG Key 에서 new SSH key로 등록한다.

  -> 이렇게 하면 로그인과 같은 효과가 나타남(PC를 바꾸면 새롭게 해야함)

  --> passphrase까지 하면 보안에 더 뛰어남.

 

git 설정

업로드할 폴더(프로젝트 폴더)로 이동 cd 폴더명

git config --global user.name "유저명 영문"

git config --global user.email "유저 Email"

git config --global push.default matching

git config --global alias.co checkout

git init

 

이렇게 하면 폴더 뒤에 (master) 가 붙는다.

 

git에 코드 저장하기

 

git add .

git commit -am "초기 커밋 메시지"

git push

 

최초 1회 연결이 필요(리포지토리는 미리 작성해둔다.)

 git remote add origin git@github.com:계정명/리포지토리명.git

 git push -u origin master

 

 passphrase를 물어본다면 입력한다

 

github.com에서 확인한다.

 

이후에는 

 

코드의 추가/수정시

 

git add .

git commit -am "커밋 메시지"

git push