英文:
How to copy the message of the previous commit into the new commit to edit it
问题
I write my commits in the following way, namely I try to document what has been done and what remains to be done (todo list):
Done:
- task1 done
Todo:
- task2
-- implement feature1
-- implement feature2
- task3
-- implement feature1
-- implement feature1
Is there a way to automatically copy the content of the previous commit into the new commit to edit (in my case, could be interesting for the todo list)
If someone has another system of "todo list" integrated with git, I am also happy to hear
英文:
I write my commits in the following way, namely I try to document what has been done and what remains to be done (todo list):
Done:
- task1 done
Todo:
- task2
-- implement feature1
-- implement feature2
- task3
-- implement feature1
-- implement feature1
Is there a way to automatically copy the content of the previous commit into the new commit to edit (in my case, could be interesting for the todo list)
If someone have another system of "todo list" integrated with git, I am also happy to hear
答案1
得分: 1
当您想要创建一个新的提交并重用当前 HEAD 提交的消息时,只需运行以下命令:
git commit -c HEAD
或者,如果您想要减少输入:
git commit -c @
(因为“@”是HEAD
的另一个名称)。
英文:
> Is there a way to automatically copy the content of the previous commit into the new commit to edit (in my case, could be interesting for the todo list)
Sure. Look at the -C
and -c
arguments to git commit
:
> -C <commit>, --reuse-message=<commit>
>
> Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.
>
> -c <commit>, --reedit-message=<commit>
>
> Like -C, but with -c the editor is invoked, so that the user can further edit the commit message.
If you want to make a new commit that re-uses the messages from the current HEAD commit, just run:
git commit -c HEAD
Or if you want to minimize typing:
git commit -c@
(Because @
is another name for HEAD
.)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论