Git 에서 자주 쓰이는 command들을 정리해보자!
1. 초기 설정
// .git 디렉토리 생성 및 local repository 생성
git init
// 사용자 등록
// '--global' 옵션: pc내의 모든 환경에서 사용
git config --global user.name {이름}
git config --global user.email {이메일}
// git 상태 확인 (repository 내 변경사항 확인)
git status
2. 저장소 관련
// 원격 저장소 복제
git clone {url 혹은 ssh}
// 원격 저장소 설정
git remote add origin {url 혹은 ssh}
// 저장소 주소 확인
git remote -v (or --version)
// 원격 저장소 제거
git remote remove origin
// 원격 저장소로부터 불러오기
git pull origin {branch (주로 master)}
3. 기본적인 snapshotting
// 업데이트 관련
// {file}을 working tree 에 올려놓음
git add {file}
// commit 생성 (변경사항 기록)
git commit -m "commit 내용"
// commit 된 내용들을 원격저장소에 업데이트
git push origin {branch 이름}
// 제거 관련
// 로컬, 원격 모두에서 삭제
git rm {file}
// 원격에서만 삭제
git rm --cache {file}
// 이전 commit 내용 확인
git log
4. Branch 관련
// local branch 확인 (종료 시 :q)
git branch
// 모든 branch 확인
git branch -a (혹은 --all)
// local branch 생성
git branch {branch 이름}
// local branch 제거
git branch -d {branch 이름}
// 다른 branch로 이동
git switch {branch name}
git checkout {branch name}
// branch 생성과 동시에 이동
git checkout -b {branch name}
Reference: https://git-scm.com/docs
'Infrastructure > Git&Github' 카테고리의 다른 글
1) GitHub 시작하기 (0) | 2023.07.27 |
---|