본문 바로가기
IT양아치

Git 명령어 모음

by 취화선26 2025. 7. 27.

git init

 

git status : 현재 상태 확인

 

git init : 초기화

 

git config --global user.name "사용자 이름"

git config --global user.email "사용자 이메일"

git config --global credential.helper store

Git 프로세스

 

그 외 명령어

git branch exp 
 → branch생성
 
git commit -am "my commit"
 → -a : add 옵션 ( 신규파일은 제외 하고 add ) 
  
git checkout main
 → 현재 branch에서 checkout 하고 main 으로 이동 

git log --branches --decorate 
 → branch 정보가 보여짐

 


 
git reset --hard HEAD
 → HEAD 의 버전으로 리셋
 
git log --branches --decorate --graph --oneline
 → decorate : branch 정보를 보여줌
 → grapt : 그래프 형태로 보여줌 
 → oneline : 한줄로 단순한 형태로 보여줌
 
git merge exp master 
 → exp를 master로 merge 하려면, git checkout master 한 후 위 명령어 수행
 
git branch -d exp 
 → exp brahcn 를 삭제 

git checkout -b iss53
 → iss53 의 branch를 만들고 checkout 한다 

 

git stash 
 → 임시로 작업하던 것을 어딘가에 잠시 숨겨놓는다. ( save는 생략 가능 ) 
   명시적으로 삭제하지 않으면, 그대로 남아있음
   git stash [save]  : 현재 working directory, index를 save(작업중 상태로 숨김)
   git stash apply : 원복
   git stash list : stash 목록 조회
   git stash drop : 가장 최신의 stash를 삭제한다
   git stash pop : apply + drop 
   

□ Git 원격저장소
git init --bare <<저장소명>>
git remote add origin <<저장소 경로>>

   : origin 은 <<저장소 경로>> 의 alias 
 → 원격 저장소 생성

git remote remove origin 
 → 원격 저장소 삭제 

git tag 1.0.0 master
 → tag 생성
 
git tag -v 1.0.0
 → tag 상세 내용 조회 

git tag -a 1.1.0 -m "bug fix"
 → -a : annotated tag 에 주석 추가 

□ Amending commits

  • 바로 직전의 commit 을 취소