[GIT] commit, push 된 버전 삭제하기
GIT commit, push 된 버전 삭제하기
이미 작업이 끝나서 commit에 remote push까지 된 상태에서 취소하는 방법을 정리해보았다.
일단 최근 commit을 취소하려면 아래의 명령을 한다.
$ git reset HEAD~
그리고 나서 git log를 확인해보면 최근 commit이 취손 된 것을 확인 할 수 있다.
이제 취소된 내역을 remote에도 반영해보자.
$ git push origin qa
Password for 'https://rocksea@bitbucket.xxxxx.co.kr':
To https://rocksea@bitbucket.xxxxxx.co.kr/bitbucket/scm/project.git
! [rejected] qa -> qa (non-fast-forward)
현재 local 브랜치와 remote 브랜치간의 버전이 안맞아서 rejected가 되는데 이 경고를 무시하고 push를 하면된다.
브랜치앞에 + 기호를 추가하면 된다.
$ git push origin +qa
Password for 'https://rocksea@bitbucket.xxxxx.co.kr':
Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: Create pull request for qa:
remote: https://bitbucket.xxxxx.co.kr/bitbucket/projects/MKT/repos/project/compare/commits?sourceBranch=refs/heads/qa
remote:
To https://rocksea@bitbucket.xxxxx.co.kr/bitbucket/scm/mkt/project.git
+ a61ec23…879dde1 qa -> qa (forced update))