반응형
1. push 전 ( 커밋이 로컬에 있을 때 )
1) 가장 최근 커밋 메시지 수정하기
git commit --amend
2) 최근이 아닌 커밋 메시지 수정
// 깃 로그부터 확인
git log
// 위에서 3번째 커밋 선택
git rebase -i HEAD~3
// 이후 아래처럼 뜨면, 수정할 커밋들을 "pick"에서 "reword"로 바꾼 후 순서대로 수정
pick e499d89 Delete CNAME
pick 0c39034 Better README
pick f7fde4a Change the commit message but push the same commit.
# Rebase 9fdb3bd..f7fde4a onto 9fdb3bd
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
2. push 후 ( 커밋이 remote에 올라간 상태 )
이때는 force로 수정된 커밋을 강제로 push 해야 한다. force pushing은 push된 커밋의 로그를 다른 팀원들이 수동으로 수정해야 하기때문에 최대한 지양해야 한다.
git push --force 브랜치이름
반응형
'기타 > git' 카테고리의 다른 글
[git] 깃 명령별(pull, merge, commit, add) 취소하고 되돌리기 (0) | 2024.03.17 |
---|---|
깃허브에 있는 파일 또는 디렉토리 삭제하는 방법 (0) | 2022.09.19 |