로컬과 github repository를 연동하기 위해서는 아래와 같은 git 명령어를 사용해야 한다.
git push origin master
git 명령어를 사용하기 위해서 Git을 설치해준다.
설치 완료 후 git bash를 연다.
git config --global user.name "본인의 영어 이름"
git config --global user.email "github 가입한 이메일"
아래 명령어를 입력해서 user.name과 user.email이 본인이 입력한 대로 잘 나왔는지 확인하면 된다.
git config --list
git init
우선 초기화를 해준다. 아래 코드를 실행하면 현재 위치한 디렉토리(pwd)에 .git 폴더가 생긴다.
git add .
.은 모든 파일을 의미한다. 특정 파일만 올리고 싶으면 . 대신 해당 파일의 이름을 입력해주면 된다.
git status
add한 현재 위치한 디렉토리(pwd)에 어떤 변화가 있었는지 알 수 있다.
git commit -m "first commit"
"first commit"은 외국판 "_최종" 이런 느낌
히스토리나 어떤 수정을 했는지 남겨준다.
로컬 저장소와 원격 저장소 연결과 연결 확인 과정은 git add . 이전에 해도 된다.
git remote add orgin 원격저장소URL
git remote -v
원격 저장소의 주소가 출력되면 잘 연결되었다는 의미이다.
git push origin master
branch 이름이 main이라면 master 대신 main 입력
git add .
git status
git commit -m "수정된 사항/second commit"
git push origin master
git branch -m new-branch-name # 로컬 브랜치 이름 변경
git push origin --delete old-branch-name # 원격 브랜치 삭제
git push -u origin new-branch-name # 새 브랜치 이름으로 푸시
git branch
연동이 잘 안 되어 여러 가지 시도를 해보다가 꼬여서 연동을 처음부터 시도하고 싶을 경우 아래와 같은 방법을 시도해볼 수 있다.
rm -rf .git
git init
git remote add origin 원격저장소URL
git add .
git commit -m "Initial commit"
git push -u origin main
https://www.youtube.com/watch?v=lelVripbt2M
https://hackmd.io/@oW_dDxdsRoSpl0M64Tfg2g/ByfwpNJ-K