상황은 3개의 commit을 git 서버에 push 했는데
코드가 잘못된걸 뒤늦게 확인해 roll-back 하고 싶을때 revert 하는 예시입니다.
상황: 3개의 commit을 git 서버에 push 한 상태
- git commit -m 'test 1'
- git commit -m 'test 2'
- git commit -m 'test 3'
- git push origin master
확인: revert 진행할 commit에 대한 hash 확인
- git log
commit <COMMIT_HASH_3> (HEAD -> master, origin/master, origin/HEAD) Author: ... Date: ... test 3 commit <COMMIT_HASH_2> Author: ... Date: ... test 2 commit <COMMIT_HASH_1> Author: ... Date: ... test 1 |
해결: 적용한 3개의 commit을 역순으로 하나씩 revert 하기
tip. revert 할때마다 revert commit history가 남는데, --no-commit 옵션을 사용하면 revert history를 1줄로 숨길 수 있음
- git revert --no-commit <COMMIT_HASH_3>
- git revert --no-commit <COMMIT_HASH_2>
- git revert --no-commit <COMMIT_HASH_1>
- git commit -m 'Revert 3 commits'
- git push origin master
출처: https://jupiny.com/2019/03/19/revert-commits-in-remote-repository/
'Programming > 개발환경' 카테고리의 다른 글
SVN 명령어 (리눅스 console) (0) | 2012.12.22 |
---|---|
GIT 사용방법 (0) | 2012.08.26 |
Visual Studio 2010 설정관련 (0) | 2012.05.05 |
Visual Studio에서 컴파일한 exe 실행할 때 dll 찾을수 없다는 에러방지 (0) | 2012.02.21 |
TinyOS nesC용 EditPlus2 구문강조 (0) | 2007.10.08 |
QT Setting for Fedora 6 (0) | 2007.09.29 |
BREW (Visual Studio 6 환경설정) (0) | 2007.05.03 |
WIPI Clet (Visual Studio 6 환경설정) (0) | 2007.03.15 |
JDBC와 MySQL의 한글깨짐 해결 (0) | 2006.07.28 |
JSP를 위한 Tomcat + Oracle 환경설정 (0) | 2006.04.04 |