본문 바로가기

개발 일기/Git

[Git] git add, git commit, git push 취소하기

git add 취소하기

git reset HEAD [file_name]

git commit 취소하기

## commit을 취소하고, staged 상태, working directory에 보존
git reset --soft HEAD^

## commit을 취소하고, unstaged 상태로, working directory에 보존
git reset --mixed HEAD^
git reset HEAD^

## commit을 취소하고, unstaged 상태로, working directory에서 삭제
git reset --hard HEAD^

## 마지막 $개 commit 취소
git reset HEAD^$

git push 취소하기

## 1. 특정 commit으로 되돌리기
git reset HEAD^
git reset [commit_id]

## 2. 되돌려진 상태에서 다시 commit
git commit

## 3. 원격 저장소에 강제로 push
git push origin [branch_name] -f
git push origin +[branch_name]

untracked 파일 삭제하기

  • -f : 파일 삭제
  • -d : 디렉토리 삭제
  • -x : 무시된 파일 삭제
git clean -f


참고 사이트

'개발 일기 > Git' 카테고리의 다른 글

[Git] Fork Repository와 원격(Remote) Repository 동기화  (0) 2021.06.09
[Git] 커밋 메세지 수정  (0) 2021.04.23