git restoregit rm --cachedgit restore --stagedgit commit --amendgit restoregit restore {파일 이름}



git restore {파일 이름} 명령어를 통해 수정 전(직전 커밋)으로 되돌아 갈 수 있다.$ git restore test.txt

git rm --cachedgit restore --stagedgit rm --cachedgit rm --cached {파일 이름}

git rm --cached {파일 이름} 명령어를 통해 Working Directory로 되돌릴 수 있음 (Unstaged == add 취소)$ git rm --cached test.txt


git restore --stagedgit restore --staged {파일 이름}



git restore --staged {파일 이름} 명령어를 통해 Working Directory로 되돌릴 수 있음 (Unstaged == add 취소)$ git restore --staged test.txt


git commit --amendStaging Area에 새로 올라온 내용이 없다면, 직전 커밋의 메시지만 수정

커밋 메시지가 변경되며 직전 커밋은 삭제되고 새로운 커밋이 생성됨




git commit --amend 명령어를 통해 직전 커밋 메세지를 수정할 수 있다.i를 눌러 입력 모드로 변경하고 커밋 메시지 수정esc를 눌러 명령모드로 변경하고 :wq 입력 후 엔터를 누르면 커밋메세지가 저장된다.

$ git commit --amend -m {커밋 메시지} 명령어로 바로 메시지를 수정할 수도 있다.
:wq):q!)Staging Area에 새로 올라온 내용이 있다면, 직전 커밋 덮어쓰기

직전 커밋은 삭제되고 새로 생성된 내용까지 포함한 새로운 커밋이 생성됨

Staging Area에 올라온 내용이 있는 파일


git commit --amend 명령어를 통해 직전 커밋 메세지를 수정할 수 있다.



이런 글은 진짜 멋있다,,