1. GitHub Repositories메뉴에서 새로운 저장소를 추가한다.

2. 원하는 저장소의 이름을 채우고 생성 버튼을 누른다. 이 저장소 생성 이후에 .gitignore 파일을 추가할 경우에는 README file 체크를 선택할 필요는 없다.


3. 원하는 경로에 새로운 로컬저장소로 만들 폴더를 생성 한 후, git bash를 실행한다.

4. readme file을 생성하지 않았을 경우, 아래의 코드로 파일 생성을 한다.


echo "# nodeJS" >> README.md
// # nodeJS 생성할 파일이 들어갈 저장소를 입력
// ">>" 추가하기 명령어
// README.md 추가할 파일명; .gitignore 파일도 같은 방식으로 추가 가능
5. git bash를 실행한 해당 폴더에 저장소 생성을 명령하고 추가한 파일을 staging -> commit 후,
원격 저장소를 로컬 저장소와 연결 설정한 후 push하여 커밋한 파일들을 원격 저장소로 전송한다.

git init // 저장소 선언
git add README.md // 위에서 생성한 파일을 staging
git commit -m "comment" // staging한 파일을 commit
git branch -M main // 여기서 master가 아닌 특정 기본 브랜치 명을 변경 가능
git remote add origin [gitURL] // 원격 저장소와 원격 저장소와 연결
git push -u origin master // 커밋한 파일들을 원격 저장소로 전송; 단 커밋 시, 설정한 기본 브랜치 명을 입력해야한다.
6. default 브랜치 명을 설정 시, 아래와 같이 브랜치 명이 변경되는 것을 확인 할 수 있다.

7. push 까지 완료 시, github 원격 저장소에 커밋 내역 확인이 가능하다.

command review
echo "# repository" >> README.md
git init
git add README.md
git commit -m "commit comment"
git remote add origin {git URL}
git push -u origin master
Leave a Reply