티스토리 뷰
1. working directory를 마지막 push 시점으로 되돌리기
2. working directory를 이전 commit 시점으로 되돌리기
1. working directory를 마지막 push 시점으로 되돌리기
git reset --hard origin/main # <repo>/<branch>, hard 옵션을 통해 working directory를 복구
reset 옵션 3가지
soft -> hard 순으로 영향 범위가 넓어진다.
1.--soft : branch ref
2.--mixed (default) : index
3.--hard : working directory
2. working directory를 이전 commit 시점으로 되돌리기
특정 파일 삭제 후 커밋
git rm testfile.txt # 삭제
git commit -m "remove testfile.txt for reset" # 커밋
로그 확인
git log -2 # 최근 2개 로그 확인

git reset --hard 13d251a73b457ffef011aae2c4e4840c55063cde # reset

3. 특정 시점 특정 파일을 restore
특정 파일 삭제
git rm src/test/Todo.vue # 파일 삭제
git commit -m "delete Todo.vue for restore test" # 커밋
로그 확인
삭제된 파일 full path를 얻기 위해 로그 확인시 파일목록도 함께 출력합니다.
# -2 : 최근 2개 로그만
# --name-status : 파일목록 표시
git log -2 --name-status

삭제되기 이전 상태인 밑줄친 시점으로 이동합니다. 해당 값은 commit hash로 불립니다.
# git restore --source <commit hash> <file path>
git restore --source 7061e5bfbcb68e737f95c771afa675a98ab77710 src/test/Todo.vue
git status

'Git' 카테고리의 다른 글
| git branch 생성, 전환, push, merge, 삭제 (0) | 2022.07.15 |
|---|---|
| Git : push 시 인증 정보 저장해서 사용하기 (0) | 2022.07.15 |
| Git : git bash에서 명령어 사용 시 ':' 안 나오도록 설정 > pager 설정 (0) | 2022.07.15 |
| Git PAT(Personal Access Token) 설정 (0) | 2022.07.15 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 오블완
- unplugin-auto-import
- vue watch 위험성
- unmounted composable
- docker image 경량화
- vue 타이머 해제
- vue 이벤트 해제
- nuxt3 structure
- unmounted document.addlistener
- 외래키 삭제
- docker multi stage build
- 티스토리챌린지
- oracle 19c 설치
- vue watch 문제점
- Oracle Database 19c install
- docker mssql
- vue unmounted
- docker mssql create database
- unmounted setinterval
- vue 리팩토링
- dockerignore
- vue onunmounted
- Oracle Database 19C 설치
- 스파르타 코딩클럽
- vue watch 대체
- nuxt3 quasar 설정
- 스마트피싱보호_캠페인
- nuxt3 eslint prettier 설정
- nuxt3 프로젝트 설정
- docker mssql 이미지 생성
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함
