Post

[Git] Git 간단 사용법 및 각종 명령어

Git 사용법과 각종 명령어에 대해 간략히 작성해보았습니다.

✅ Git 사전 준비

User Name과 Email을 전역으로 설정해준다.

1
2
git config --global user.name {name}
git config --global user.email {email}
✔️ 정상적으로 등록이 잘 되었는지 확인하기
1
2
3
4
git config --global --list

> user.name="{name}"
> user.email="{email}"

✅ Git clone

$ git clone {Repository URL}로 clone 해올 수 있다.

만약 특정 브랜치 하나만 clone 하고 싶다면? git clone -b {branchName} --single-branch {Repository URL}

✅ Git 기초 흐름

1
2
3
4
5
6
git init                      // 저장소 설정
git add .                     // 모든 변경사항 Stage Area로 올림
git status                    // add 이력 확인
git commit -m "{message}"     // 커밋하기 (Stage Area에서 Repository로 전송)
git remote add origin {url}   // 원경 저장소(remote) 설정. origin 이름으로 추가.
git push                      // 최종 업로드
  1. git clone을 통해 Repository를 clone 해왔다면,
    git remote add origin {url} 부분을 수행할 필요가 없음
  2. git push는 뒤에 origin main이 생략되어있는 것임
    • 즉 원형은 git push origin {branchName}이고
    • origin의 branchName에 push 하겠다는 의미

✅ Branch 관련 명령어

git branch
branch 목록 확인
git branch {branchName}
branchName으로 branch 생성
git checkout {branchName}
branchName의 branch로 checkout
git pull origin {branchName}
branchName의 특정 branch만 pull 하기
This post is licensed under CC BY 4.0 by the author.

[VS Code] Prettier 일부 파일 예외처리 방법

-