1장 git 이란
Must Have 박미정의 깃&깃허브 입문 정리 MOC
깃 의 장점
- 이력 기록 및 추적
- 원격 저장소 및 공유
- 변경 이력 병합
깃허브 장점
- 호스팅 서비스
- 공개 및 비공개 서비스
- 고급 기능
지역저장소에 커밋해보기
git init
명령어 입력하면 깃 지역 저장소로 지정됨.
git config
로 깃 지역 저장소에 사용자 등록
git init
>> Initialized empty Git repository in /home/chanho/git/chapter-basic/.git/
git config user.name "usablechan"
git config user.email "lch8910@naver.com"
생성된 git 디렉토리에 READM.md 를 생성하고 add 한 후 commit 해준다.
# README.md 파일 커밋에 포함될 파일로 등록
git add README.md
# commit 생성
git commit -m "저장소 설명 추가"
>>[master (root-commit) 0140ffc] 저장소 설명 추가
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.md
git log
명령어로 log 확인
git log
>> commit 0140ffc0ebf1ea226d5e2e328cc5d82be7b4ff04 (HEAD -> master)
Author: usablechan <lch8910@naver.com>
Date: Mon Feb 6 13:46:25 2023 +0900
저장소 설명 추가
원격저장소(github)에 연결
github에서 repository 하나 만들고 해당 repository의 ssh 복사해옴
https 는 github 에서 보안문제로 인해서 또 다른 key 인증해야해서 귀찮아서 ssh 이용.
git remote add origin git@github.com:usablechan/chapter-basic.git
git branch -M main
git push -u origin main
>> Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 235 bytes | 235.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:usablechan/chapter1-basic.git
* [new branch] main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
origin
은 특정 원격 저장소를 식별하는 이름. 지역 저장소 하나에 여러 원격 저장소 등록할 수 있음. 보통 origin을 사용함.
git branch -M main
은 책에서는 안나왔는데, 안돼서 github 이 시키는 대로 해봄.
origin
은 리모트 저장소 이름, main
은 리모트 저장소의 브랜치 이름이다.