Git/Git

[Git] Git의 3가지 영역

갈푸라떼 2022. 1. 28. 03:37

# Git의 3가지 영역

* Working directory

  • untracked: Add된 적 없는 파일, ignore 된 파일
  • tracked: Add된 적 있고 변경내역이 있는 파일
  • git add 명령어로 Staging area로 이동

 

* Staging area

  • commit을 위한 준비 단계
    • 예시: 작업을 위해 선택된 파일들
  • git commit 명령어로 repository로 이동

 

* Repository

  • .git directory라고도 불림
  • commit이 된 상태

 

# 파일의 삭제와 이름 변경

* git rm

  • git rm [파일명] 명령어를 통해서 파일 삭제
    • git reset --hard로 복원가능
  •  

* git mv

  • git mv [원본 이름] [변경할 이름]
    • git status를 통해서 확인해보면 변경된 내역이 있는것을 확인할 수 있다.

 

 

# 파일을 staging area에서 working directory로 이동

git restore --staged (파일명)
  • --staged를 빼면 working directory에서도 제거
  • 예전 방식: git reset HEAD (파일명)

 

# reset의 세 가지 옵션

  • --soft: repository에서 staging area로 이동
  • --mixed (default): repository에서 working directory로 이동
  • --hard: 수정사항 완전히 삭제