如何将前一个提交的消息复制到新的提交中以进行编辑

huangapple go评论52阅读模式
英文:

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.)

huangapple
  • 本文由 发表于 2023年2月19日 18:50:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75499584.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定