Git
[Git] 취소 상황
qoth_0
2023. 12. 12. 10:35
728x90
반응형
git 취소 상황
- 특정 STEP까지의 저장 사항을 취소
- working directory의 수정사항 취소
- add 이후 취소
- commit 이후 취소
- push 후 origin까지 배포된 사항 취소
- working directory의 수정사항 취소
- git checkout .
- 파일 수정사항의 취소
- .은 현재 head위치 commit으로 checkout 함으로서 working directory의 수정사항을 취소
- git clean -fdx
- 파일을 신규추가(untracked file)한 경우의 취소
- git checkout . | git clean -fdx
- 수정 및 추가 모두 취소
- 개발툴(intellij, vscode등) 사용 시 쉽게 수정사항 취소 가능
- git checkout .
- add 이후 취소
- test2.txt 신규생성
- git status → untracked file
- git add . 후 git status → Changes to be committed
- git add 취소
- git reset 또는 git restore --staged
- commit 이후 취소
- git reset HEAD~1(또는 HEAD^)
- unstaged 상태로 만듬 : 워킹디렉토리까지 돌아감
- git reset —soft HEAD~1
- staged 상태 유지 : 커밋 직전 상태까지 돌아감
- git reset HEAD~1(또는 HEAD^)
- push 후 origin까지 배포된 사항 취소
- git revert 커밋ID
- 특정 커밋버전을 취소시키는 새로운 commit을 생성하기 때문에 push만 하면 됨
실습


add 한 후 git status로 확인

add 취소(reset) 후 status확인

commit까지 한 후 취소(reset HEAD) → git status 확인

commit까지 한 후 취소(reset --soft HEAD) → git status 확인

push까지 한 이후 git revert로 취소 후 다시 push





커밋을 취소시키는 커밋아이디 생성됨 - 3a0088

반영완료
728x90
반응형