반응형
첫 번째 git 커밋 메시지를 어떻게 바꾸나요?
3 개의 커밋을 포함하는 작업 트리가 있습니다.
➜ ~ myproject git :( 마스터) git log
commit a99cce8240495de29254b5df8745e41815db5a75
Author: My Name <my@mail.com>
Date: Thu Aug 16 00:59:05 2012 +0200
.gitignore edits
commit 5bccda674c7ca51e849741290530a0d48efd69e8
Author: My Name <my@mail.com>
Date: Mon Aug 13 01:36:39 2012 +0200
Create .gitignore file
commit 6707a66191c84ec6fbf148f8f1c3e8ac83453ae3
Author: My Name <my@mail.com>
Date: Mon Aug 13 01:13:05 2012 +0200
Initial commit (with a misleading message)
이제 첫 번째 커밋reword
의 커밋 메시지를 원합니다 (6707a66).
➜ ~ myproject git :( 마스터) git rebase -i 6707
(… vim 입력)
pick 5bccda6 Create .gitignore file
pick a99cce8 .gitignore edits
# Rebase 6707a66..a99cce8 onto 6707a66
#
# 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
이 경우 reword
문제의 커밋 메시지 를 수정하고 싶습니다 ( git parlance).
초기 커밋 (오해의 소지가있는 메시지 포함)
… 적절한 것으로.
당연히 첫 번째 커밋에는 부모 커밋 이 없기 때문에 위의 시도가 성공하지 못했습니다 . (그리고 당신이 원하는 것 보다 먼저rebase
다음으로 오래된 커밋을 참조해야 할 때 , 맞습니까?)reword
내 질문의 요지는 다른 방법으로 이것을 달성 할 수 있습니까?
하다 git rebase -i --root
( root
특정 커밋을 가리키는 대신 가리킴)
이런 식으로 첫 번째 커밋도 포함되며 reword
다른 커밋과 마찬가지로 할 수 있습니다 .
이 --root
옵션은 Git v1.7.12
(2012) 에서 도입되었습니다 . 그 이전 만 옵션을 사용하는 것이 었 filter-branch
또는 amend
일반적으로 더 열심히해야 할 일이다.
참고 : 이 유사한 질문 및 답변을 참조하십시오 .
항상 다음을 사용할 수 있습니다 git filter-branch --msg-filter
.
git filter-branch --msg-filter \
'test $GIT_COMMIT = '$(git rev-list --reverse master |head -n1)' &&
echo "Nice message" || cat' master
pcreux의 요지 는 첫 번째 커밋을 바꾸는 좋은 방법입니다.
# You can't use rebase -i here since it takes the parent commit as argument.
# You can do the following though:
git checkout FIRST_COMMIT_SHA && git commit --amend && git rebase HEAD master
참고 URL : https://stackoverflow.com/questions/11987914/how-do-i-reword-the-very-first-git-commit-message
반응형
'program story' 카테고리의 다른 글
Vim에서 "계속하려면 Enter 키를 누르거나 명령을 입력하십시오"프롬프트를 비활성화하려면 어떻게해야합니까? (0) | 2020.08.28 |
---|---|
on ()에서도 이벤트 바인딩을 복제하지 않는 jQuery clone () (0) | 2020.08.28 |
Visual Studio Code를 Git MergeTool의 기본 편집기로 사용하는 방법 (0) | 2020.08.28 |
HttpURLConnection에서 InputStream 개체를 가져 오는 동안 FileNotFoundException이 발생했습니다. (0) | 2020.08.28 |
Git / Git Extension에서 "squash"와 "fixup"의 차이점은 무엇입니까? (0) | 2020.08.28 |