在'git commit'之前写入git commit消息 [英] Write git commit message before 'git commit'

查看:112
本文介绍了在'git commit'之前写入git commit消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习来自Perforce的Git。



据我所知,必须在提交时按照与提交相同的步骤编写提交信息。或者我错过了如何在早些时候编写消息并让它一直存在,直到我准备好提交。



我非常喜欢perforce中的工作流程,您可以编辑它随时更改列表说明,然后在您准备好时签入。就我个人而言,我喜欢多次打开说明文档并记录下我的代码,或者考虑一些值得注意的事情。



可以用Git吗?

解决方案

查看 -t< file> 标志,使用 git commit



这允许您指定一个文件作为提交消息的基础。编辑器仍然被调用,但至少您可以使用提前创建的提交消息。



或者,还有另一个工作流程可以使用git,它可能更适合你的工作方式:

使用git,你可以在主线上的一个单独的分支上工作,并使用他们自己的许多小提交消息。尽管这些提交都可能无法解决您正在处理的问题,但它们确实提供了一种使用与您在提交消息文件中更新的消息类似的消息来保存工作的中间状态的方法。 / p>

一旦您准备好完成工作,可以使用 rebase 命令和 squash 这些提交在一起。然后,您的编辑器将与您用于较小提交的所有单个消息一起调用,然后您可以将它们一起编辑成单个消息。



这样更容易比它听起来在这里,恕我直言,一个更类似git的方法。


I'm learning Git coming from Perforce.

As far as I can tell you must write the commit message in the same step as when you commit. Or am I missing how I might write the message earlier and have it hang around until I'm ready to commit.

I really liked the workflow in perforce where you can edit the changelist description at any time, and then checkin when you're ready. Personally, I like to open the description many times and document as I code, or as I think of noteworthy things to point out.

Possible with Git?

解决方案

Have a look at the -t <file> flag with git commit

This lets you specify a file to use as the basis for the commit message. The editor is still invoked but at least you can use a commit message which you create in advance.

Alternatively, there is another workflow that you can use with git that might better suit your way of working:

With git you can work on a separate branch from the main line and make lots of small commits with their own messages. Although each of these commits by themselves may not solve the problem that you are working on, they do provide a way of saving the intermediate states of your work with the same sort of messages that you may have been updating in your commit message file.

Once you are ready to commit the sum of your work, you can use the rebase command and squash these commits together. Your editor will then be invoked with the all the individual messages that you used for the smaller commits which you can then edit together into a single message.

This is a lot easier than it sounds here, and is IMHO a more git-like approach.

这篇关于在'git commit'之前写入git commit消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆