Infra/Git & SVN
되돌리기 명령어 정리
전봉근
2019. 3. 8. 14:31
반응형
[git 되돌리기]
# 특정 파일의 수정 되돌리기(git add 명령으로 stage에 올리지 않은 경우)
1. repositoryt내 모든 수정 되돌리기
- cd {repository_root_dir}
- git checkout .
2. 특정 폴더 아래의 모든 수정 되돌리기
- git checkout {dir}
3. 특정 파일의 수정 되돌리기
- git checkout {fine_name}
# git add 명령으로 stage에 올린 경우
1. git reset
# commit을 한 경우
1. git reset --hard HEAD^
- master 브랜치의 마지막 커밋을 가리키던 HEAD를 그 이전으로 이동시켜서 commit 내용을 없앰
2. git reset HEAD^
- commit은 취소하고 commit했던 내용은 남기고 unstaged상태로 만들기
3. git reset --soft HEAD^
- commit은 취소하고 commit 했던 내용은 남기고 staged 상태로 만들기
4. git push를 한 경우 remote repository도 이전으로 되돌리기
- git reset HEAD^ #local repository에서 commit을 하나 되돌림
- git commit -m "..." #되돌린 것으로 commit
- git push origin +master #remote repository를 강제로 revert
반응형