728x90

설정

전역 설정 - 이름/이메일 

git config --global user.name “Your name”
git config --global user.email “Your email address”

로컬 설정 - 이름/이메일  (해당 디렉토리)

git config user.name “Your name”
git config user.email “Your email address”

전역 설정 조회

 git config --global --list

로컬 설정 조회

git config --list

저장소 생성

git init

저장소 clone

git clone <저장소주소>

# 예) https타입 (필요정보 : 아이디/비밀번호)
# git clone https://github.com/계정/저장소.git 

# 예) ssh타입 (필요정보 ssh key)
# git clone git@github.com:계정/저장소.git

브랜치

로컬 목록

git branch

# 상세정보
git branch -v

원격 목록

git branch -r

로컬 + 원격 목록

git branch -a

생성

git branch <브랜치이름>

전환

 git checkout <브랜치이름>

생성 + 전환

 git checkout -b <브랜치이름>

원격 push

git push origin <브렌치이름>

삭제

# 병합되어있을 경우 삭제
git branch -d <브랜치이름>

# 대문자 D는 "--delete", "--force"를 의미함 병합 여부와 관계없이 삭제
git branch -D <브랜치이름>

# 원격 브랜치 삭제
git push origin --delete <브랜치이름>

 

 

add & status & commit

스테이징에 파일 추가

# 특정 파일 추가
git add <파일명>

# 명령어 실행한 디렉토리 이하 변경사항 추가
git add .

# 모든 변경사항 추가
git add -A

# .gitignore에 있는 파일도 추가
git add *

파일 상태 확인

git status

커밋

git commit -m "메세지"

병합

원격 fetch

git fetch origin

원격 fetch & merge

git pull

현재 브랜치에 다른 브랜치 병합

git merge <브랜치이름>

태그

조회

# 전체 조회
git tag

# 조건에 맞는 태그 조회
git tag -l "v1.*"
git tag --list "v1.*"

# 체크섬 
git show-ref --tags

# 태그에 정보
git show v1.0.0

# 원격저장소 조회
git ls-remote --tags

생성

# Annotated
git tag -a <태그이름> -m "<메세지>"

# lightweight
git tag <태그이름>

# 특정 커밋에 tag생성
git tag -a <태그이름> <커밋 체크섬>

원격 push

# 1개
git push origin <태그이름>

# 전체
git push origin --tags

수정

# annotated 태그
git tag -a <새로운태그이름> <이전태그이름>^{} -m "<새로운태그메세지>"
git tag -d <이전태그이름>

# lightweight 태그
git tag -a <새로운태그이름> <이전태그이름>
git tag -d <이전태그이름>

삭제

# 로컬
git tag -d <태그이름>

# 원격
git push origin :refs/tags/<태그이름>
git push origin :<태그이름>
git push origin -d <태그이름>

이동

git checkout tags/<태그이름>

태그기반 브랜치 생성

git checkout tags/<태그이름> -b <브랜치이름>
728x90

'퍼블리싱 > git' 카테고리의 다른 글

github 대용량 파일 올리기  (0) 2023.04.06
github private 저장소 git clone 하기  (0) 2023.04.05
.gitignore  (0) 2023.03.26
git branch 전략 - GitHub flow  (0) 2023.03.10
git branch 전략 - Git flow  (0) 2023.03.10

+ Recent posts