이제 변경사항을 깃허브에 올려보자.
올리기 전에 github에 repository를 만들어야 한다. repository는 그냥 저장소라고 생각하면 된다. github에 접속해서 새로운 repository를 만든다. repository 페이지에서 new버튼을 누르면 된다.
repository name을 입력하고 공개와 비공개 중에 선택한다.
public은 공개 private는 비공개다. public을 선택하면 아무나 볼 수 있다.
repository를 만들면 아래와 같이 두가지 방법중 하나를 택해서 로컬(내 컴퓨터)과 원격저장소를 연결할 수 있다.
…or create a new repository on the command line
echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:dolljong/test.git
git push -u origin main
…or push an existing repository from the command line
git remote add origin git@github.com:dolljong/test.git
git branch -M main
git push -u origin main
첫번째 command line 명령들은 내 컴퓨터에서 git init도 안하고 아무것도 안했을 때 적용한다. 즉 원격저장소에서 repository를 먼저 만들고 내 컴에서 새 repository를 만들었을 때 적용하는 명령들이다. 간단하게 설명하면 echo 명령으로 readme.md파일을 만든다. 그리고 git init로 초기화 한다. git add readme.md로 readme.md 파일을 스테이징한다. git commit -m "first commit"으로 커밋한다. 그리고 git branch -M main는 main이라는 브랜치를 만드다.
그 다음이 내 컴과 깃허브를 연결하는 명령이다. dolljong은 깃허브 아이디, test가 repository이름이다.
git@github.com:dolljong/test.git