git .git目录提交
Are you a developer who has recently started using Git? If you are wondering how to create a good commit message for your project, then this article is made for you.
您是最近开始使用Git的开发人员吗? 如果您想知道如何为您的项目创建良好的提交消息,那么本文就是为您准备的。
After a few weeks away from writing, I’m coming back today with a follow-up to one of my most searched posts on Google.
在写了几周之后,我今天要回访我在Google上搜索次数最多的帖子之一。
When I started to write, one year ago, I created an article on how to start and create your first repository with Git.
一年前,当我开始写作时,我写了一篇文章, 介绍如何使用Git启动和创建您的第一个存储库 。
This article helps many people each week. So I decided to write this post on how to write a good commit message so you can take your Git skills to the next level.
这篇文章每周帮助许多人。 因此,我决定写这篇关于如何编写良好提交信息的文章,以便您将Git技能提高到一个新的水平。
什么是好的提交消息? (What is a good commit message?)
As a short reminder, a commit message is the short text you left when you saved your work on Git. This message aims to identify your work.
简短提醒一下,提交消息是在Git上保存工作时留下的简短文本。 此消息旨在标识您的工作。
The idea is that just bu reading it, anyone will be able to clearly understand what you did in this part of your work.
这个想法是,只要阅读它,任何人都可以清楚地了解您在这部分工作中做了什么。
一个很好的提交示例 (A good commit example)
Below, you can find the last commits to the Angular.js project on GitHub. As you can see, messages are clear, and we can better understand which work has been done in different parts.
在下面,您可以找到GitHub上对Angular.js项目的最后提交。 如您所见,消息很清晰,我们可以更好地了解在不同部分完成了哪些工作。
For example, on July 24, 2019, “gkalpak” upgraded “SauceConnect” and switched to the last version of Safari (the web browser).
例如,在2019年7月24日,“ gkalpak”升级了“ SauceConnect”并切换到了Safari的最新版本(Web浏览器)。
为什么每个人都不以相同的方式承诺? (Why is everyone not committing the same way?)
Unfortunately, there’s not a universal way to write commits. Each project and each company define specific rules for their needs.
不幸的是,没有通用的提交方式。 每个项目和每个公司都为其需求定义特定的规则。
But don’t worry – you will often find similar ways of writing a message.
但是不用担心–您通常会找到类似的消息编写方式。
To find out what those are, I highly recommend that you read the rules before starting at a company or working on an open-source project.
为了弄清楚这些是什么,我强烈建议您在公司成立或从事开源项目之前,先阅读规则。
I will give you more details on these guidelines later in this article.
在本文后面的部分中,我将为您提供有关这些准则的更多详细信息。
为什么写好承诺很重要 (Why it is essential to write your commit well)
I created a short list of the advantages of using a good commit message.
我创建了一个简短列表,列出了使用良好提交消息的优势。
更好的协作 (Better collaboration)
If you are working at a company, or on an open-source project, it’s essential to follow the rules for better cooperation. If you write something understandable, following the rules of the project, other developers will be able to work more efficiently. They won’t have to ask you questions about your work.
如果您在公司中工作,或者在开源项目中工作,那么必须遵循规则以实现更好的合作。 如果您编写的内容易于理解,那么按照项目规则,其他开发人员将能够更有效地工作。 他们不必问您有关工作的问题。
Note: If you are working on a personal project, I highly recommend that you also follow specific rules. It will improve your productivity, and if you need help from another developer, it will be easier for them to start working on your project.
注意:如果您正在处理个人项目,强烈建议您也遵循特定规则。 这将提高您的生产力,并且如果您需要其他开发人员的帮助,他们开始进行项目的工作也会更容易。
更好的理解 (Better understanding)
You need to create clear and understandable messages. This will help you and your collaborator work on a project together. Below, you can find an example of a git commit history with only unclear messages. As you will see, it’s difficult to understand what was going on.
您需要创建清晰易懂的消息。 这将帮助您和您的合作者一起完成一个项目。 在下面,您可以找到仅带有不清楚消息的git commit历史记录示例。 如您所见,很难理解发生了什么。
奖金-变更日志生成 (BONUS – A changelog generation )
I’ll tell you a small secret: if you write good messages, you will be able to generate a changelog directly from your commit messages.
我将告诉您一个小秘密:如果您编写良好的消息,您将能够直接从提交消息中生成变更日志。
Here are a few tools to do it:
这里有一些工具可以做到这一点:
-
Github Changelog Generator
Github Changelog生成器
-
Git Chglog
吉特·科格洛
-
Auto Changelog
自动变更日志
-
Conventional Changelog.
常规变更日志 。
I’ll write an upcoming article on this topic, too. If you want to be updated, you can follow me on Twitter. I post every update there.
我还将就该主题写一篇即将发表的文章。 如果要更新, 可以在Twitter上关注我 。 我在那里发布每个更新。
Note: If you want to have more example of bad commits and have fun at the same time, a Twitter account named “gitlost” is tweeting every day with the funny and unfiltered commits.
注意:如果您想更多地提交错误的提交示例并同时玩得开心,那么一个名为“ gitlost”的Twitter帐户每天都会在推特上发布有趣且未经过滤的提交。
OK, now let’s get into more detail and look at what it really takes to write a good commit message.
好的,现在让我们更详细地了解写一条好的提交消息的实际需求。
如何编写提交消息 (How to write a commit message)
If you want to write a good commit message, you need to follow some rules. I created a checklist below. Every time you want to commit, take the time to refer to this list.
如果要编写良好的提交消息,则需要遵循一些规则。 我在下面创建了一个清单。 每次您要提交时,请花时间参考此列表。
-
Always check your grammar. It’s never pleasant to read a message full of errors. To do this, I recommend you to use a grammar tool. If you are writing in English, you can use Grammarly, Reverso, or GrammarCheck. These tools are not perfect, but they will remove most of your errors.
经常检查语法。 阅读充满错误的消息永远不会令人愉快。 为此,建议您使用语法工具。 如果您使用英语写作,则可以使用Grammarly , Reverso或GrammarCheck 。 这些工具并不完美,但是它们将消除您的大多数错误。
-
One commit, one change. Try to commit often. It is ideal to have each change in a different commit. It will be easier for you to go back to your previous work.
一提交,一改变。 尝试经常提交。 最好使每个更改都处于不同的提交中。 您可以更轻松地回到以前的工作。
-
Be clear. When you are writing a commit, try to be as transparent as possible. I recommend that you use simple English and get straight to the point.
清楚。 在编写提交时,请尝试尽可能透明。 我建议您使用简单的英语,然后直接讲。
-
Detail what you did. Take the time to reread your code to write what you did. In case you need to add a lot of detail, use the description part of the commit.
详细说明您的工作。 花时间重新阅读代码以编写您所做的事情。 如果您需要添加很多细节,请使用提交的描述部分。
git commit命令 (The git commit command)
I want to share more details on the ‘git commit’ command. If you are not using a git software, you should know that you can create detailed commits by typing this command:
我想分享有关’git commit’命令的更多详细信息。 如果您不使用git软件,则应该知道可以通过键入以下命令来创建详细的提交:
$ git commit -m "Title" -m "Description"
It’s the same as before, but with a second part for the description. So, “-m ‘title’ ” lets you write the short title of the commit, and “-m ‘description’ ” lets you write the description if you need to give more details.
与以前相同,但有第二部分进行描述。 因此,如果需要提供更多详细信息,可以使用“ -m’title”“来编写提交的简短标题,使用” -m’description“”可以编写描述。
使用git准则 (Use git guidelines)
If you want to have a clear git commit history, you should follow some guidelines. In my case, I chose this simple one from Udacity.
如果要清除git提交历史记录,则应遵循一些准则。 就我而言,我从Udacity中选择了一个简单的示例。
There are a lot of others, like Conventional Commits, and Angular Guideline. A commit guideline will help you give structure to your commits.
还有很多其他内容,例如常规提交和Angular Guideline 。 提交指南将帮助您为提交提供结构。
For example, adding a tag to clarify what you did: “git commit -m ‘fix: correctly delete all user information when the button delete account is triggered'”.
例如,添加标签以阐明您的操作:“ git commit -m’修复:在触发按钮删除帐户时正确删除所有用户信息’”。
结论 (Conclusion)
I hope that you liked this guide on how to commit to Git! If you have any questions or feedback, feel free to ask.
我希望您喜欢本指南,了解如何使用Git! 如果您有任何问题或反馈,请随时提出。
If you have any other tips on how to make good commits, please let me know.
如果您还有其他有关如何做出良好承诺的提示,请告诉我。
Don’t miss my content by following me on Twitter and Instagram.
在Twitter和Instagram上关注我,不要错过我的内容。
You can find other articles like this on my website: herewecode.io.
您可以在我的网站上找到其他类似的文章: herewecode.io 。
想要更多? (Want more?)
-
Each week get a motivational quote with some advice, a short tutorial in a few slides, and one developer’s picture on Instagram.
每周都会收到一些激励性的报价,其中包含一些建议,一些幻灯片中的简短教程以及Instagram上一张开发人员的照片。
-
Sign-up for the newsletter and get the latest articles, courses, tutorials, tips, books, motivation, and other exclusive content.
注册时事通讯并获取最新文章,课程,教程,技巧,书籍,动机和其他独家内容。
翻译自: https://www.freecodecamp.org/news/a-beginners-guide-to-git-how-to-write-a-good-commit-message/
git .git目录提交
今天的文章git提交当前目录下的修改_创建git仓库有什么用分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/82664.html