Blog categories

Comments

[Git] Commit 실행 취소 및 삭제

[Git] Commit 실행 취소 및 삭제

로컬 커밋 취소

작업 내역 확인

git reflog

작업 실행 취소

History 최상단의 1개 작업 실행 취소

git reset HEAD@{1}

Commit 삭제

HEAD에서부터 3개 commit 삭제

git reset --hard HEAD~3

혹은 아래와 같은 형식으로도 가능

git reset --hard HEAD^^^

워킹 트리를 보존할 때에는 아래와 같이 -hard 키워드를 제외하고 작성.

git reset HEAD~3

* 참조 : reset 옵션
–soft : Index 보존, 워킹 트리 보존
–mixed : Index 취소, 워킹 트리만 보존 ( Default)
–hard : Index 취소, 워킹 트리 취소

원격 커밋 취소

원격 커밋 삭제

git push <<remote>> +<<commit>>^:<<branch>>

예를 들면 아래와 같이 할 수 있다.

git push origin +4b1ab7b^:master

원격 커밋 취소

이외에 revert 시키는 방법도 있다.

get revert <<commit>>

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

div#stuning-header .dfd-stuning-header-bg-container {background-color: #3f3f3f;background-size: cover;background-position: top center;background-attachment: initial;background-repeat: no-repeat;}#stuning-header div.page-title-inner {min-height: 350px;}#main-content .dfd-content-wrap {margin: 0px;} #main-content .dfd-content-wrap > article {padding: 0px;}@media only screen and (min-width: 1101px) {#layout.dfd-portfolio-loop > .row.full-width > .blog-section.no-sidebars,#layout.dfd-gallery-loop > .row.full-width > .blog-section.no-sidebars {padding: 0 0px;}#layout.dfd-portfolio-loop > .row.full-width > .blog-section.no-sidebars > #main-content > .dfd-content-wrap:first-child,#layout.dfd-gallery-loop > .row.full-width > .blog-section.no-sidebars > #main-content > .dfd-content-wrap:first-child {border-top: 0px solid transparent; border-bottom: 0px solid transparent;}#layout.dfd-portfolio-loop > .row.full-width #right-sidebar,#layout.dfd-gallery-loop > .row.full-width #right-sidebar {padding-top: 0px;padding-bottom: 0px;}#layout.dfd-portfolio-loop > .row.full-width > .blog-section.no-sidebars .sort-panel,#layout.dfd-gallery-loop > .row.full-width > .blog-section.no-sidebars .sort-panel {margin-left: -0px;margin-right: -0px;}}#layout .dfd-content-wrap.layout-side-image,#layout > .row.full-width .dfd-content-wrap.layout-side-image {margin-left: 0;margin-right: 0;}