git status
- repository의 상태 확인
- 현재 브랜치의 이름과 생성 / 변경 / 삭제된 파일 및 디렉토리 목록을 표시
- commit하지 않은 변경사항 확인
git status
git log
- local repository의 commit 히스토리 탐색
git log --oneline --all --graph
-
- —oneline: 각 commit을 요약해서 보여줌
- —all: 모든 branch를 보여줌
- -n: 탐색할 commit 히스토리의 개수를 지정
- —graph: commit 히스토리를 그래프 형태로 보여줌
git reflog
- commit / rebase / reset 등의 히스토리 탐색
git reflog
git reset
git reset --hard <commit_id>
-
- —hard: reset 옵션
- commit id는 git reflog로 확인 가능
- checkout vs reset
- checkout = HEAD를 바꾼다
- reset = HEAD의 Branch를 바꾼다
git revert
- 선택한 commit을 취소하는 commit을 생성
git revert <commit_id>
- reset vs revert
- reset: 선택한 commit을 취소
- 다른 사람들과 협업하는 상황에서 사용할 경우 conflict 발생
- revert: 선택한 commit을 취소하는 commit을 생성
git commit —amend
git commit --amend -m "version 8"
댓글