atom 中首次使用git

by Hasit Mistry

通过Hasit Mistry

使用Atom获得更好的Git提交消息 (Get Better Git Commit Messages with Atom)

Recently, I came across two enlightening posts about writing better Git commit messages. These posts give suggestions about how a well structured commit message should look like, and provide clear examples.

最近,我遇到了两个有关编写更好的Git提交消息的启发性文章。 这些帖子提供了有关结构良好的提交消息外观的建议,并提供了清晰的示例。

  • Better Commit Messages with a .gitmessage Template by Matthew Summer

    使用 Matthew Summer 的.gitmessage模板更好地提交消息

  • How to Write a Git Commit Message by Chris Beams

    如何编写 Chris Beams 的Git提交消息

These two blog posts made me go back to my repositories and read my commit messages. And to be honest, I felt a little ashamed of my past then.

这两个博客文章使我返回到存储库并阅读了提交消息。 老实说,那时我对自己的过去感到有些ham愧。

You may ask, “why are commit messages even important?” If you find yourself asking that question, you are like the one-week-younger version of me.

您可能会问,“为什么提交消息甚至很重要?” 如果您发现自己在问这个问题,那就像是我一个星期的孩子。

Just to give you an idea, Figure 1 shows some of the commit messages from my project licensethis. I promise that the code is much better than the commit messages.

为了给您一个想法,图1显示了我的项目licensethis中的一些提交消息。 我保证代码比提交消息要好得多。

It’s unsurprising how little these commit messages actually tell me about my past work. That’s because I didn’t take writing them seriously.

这些提交消息实际上告诉我有关我过去的工作的信息不足为奇。 那是因为我没有认真对待它们。

In order to actually understand which changes each commit contributed, I had to go into each commit and read the changes line-by-line. This is tedious to say the least.

为了真正了解每个提交所做的更改,我必须进入每个提交并逐行阅读更改。 至少可以说这很乏味。

At the time of authoring these commit messages, I invariably blurted out whatever made sense to me at that moment, with no consideration of how I — or anyone else for that matter — would understand the text at a later stage.

在编写这些提交消息时,我总是脱口而出当时对我有意义的任何内容,而没有考虑我-或其他人在以后的阶段将如何理解文本。

First, let’s synthesize all the information we’ve absorbed from the above-mentioned blog posts. Then I’ll give working tips on how Atom can be used as a tool for writing better commit messages for myself and others who are interested in doing the same.

首先,让我们综合从上述博客文章中吸收的所有信息。 然后,我将提供一些工作提示,说明如何将Atom用作为自己和其他有兴趣这样做的人编写更好的提交消息的工具。

Note that I am not going to write about how to write a good commit message. Chris Beams’s wonderful post on How to Write a Git Commit Message explains just that and more in seven rules.

请注意,我不会写有关如何编写好的提交消息的文章。 克里斯·比姆斯 ( Chris Beams )在有关如何编写Git提交消息的精彩文章中,用七个规则对此进行了解释。

Before we begin, let us look at this following text block to understand what is considered as a properly-structured, purposeful, and well-written commit message:

在开始之前,让我们看一下下面的文本块,以了解什么被认为是结构正确,有目的且写得很好的提交消息:

# Subject in (preferably) less than 50 charactersThis is the subject of this commit message
# Body in greater detailThis is the body of this commit message. The body is written after the subject line with one blank line in between. The blank line is used by various tools (such as 'git log', 'git show', etc.) to differentiate subject from body. Further paragraphs are also separated by blank lines.
Explain the problem being solved by this commit. More importantly, explain why these changes are being made, as opposed to how. The 'why' part is your responsibility, the 'how' part is code's responsibility.
- You can also use bullets like this.- Or, like this.

Some great examples of such commit messages can be found over at the Linux and Git repositories on GitHub.

可以在GitHub上的Linux和Git存储库中找到此类提交消息的一些很好的示例。

Now, it is understandable that not every commit brings big changes to the repository. Some commits would be for fixing typos, and others for changing line order or indentation. In such cases, a subject line by itself should suffice.

现在,可以理解的是,并非每次提交都会对存储库带来重大变化。 一些提交用于修复错别字,而其他提交则用于更改行序或缩进。 在这种情况下,主题行本身就足够了。

Atom is a text editor that I use for everything! I use it to take notes in class, complete writing assignments in Markdown (unless I absolutely require the super powers of MS Word), and for programming projects on a daily basis.

Atom是我用于所有操作的文本编辑器! 我用它在课堂上做笔记,在Markdown中完成写作作业(除非我绝对需要MS Word的超级能力),以及用于日常项目编程。

I keep tweaking Atom little-by-little every time I learn something new, it’s fun to watch my config files slowly grow in size.

每次学习新知识时,我都会不断地对Atom进行微调,很有趣的一点是,我的配置文件的大小逐渐变大。

So let us start by setting Atom as our default commit editor for git, and checking if the same has happened correctly using the following commands in your terminal:

因此,让我们从将Atom设置为git的默认提交编辑器开始,并使用以下命令在终端中检查是否正确发生了该操作:

git config --global core.editor "atom --wait"
git config --get core.editor
# Which should give you the output: atom --wait

根据其长度更改主题线的颜色 (Change the color of the subject line according to its length)

First, we will set up Atom so that it changes the color of the subject line to orange if the length exceeds 50 characters and to red if the length exceeds 65 characters. You can read more about git integrations for Atom at Git Integration.

首先,我们将设置Atom,以便如果长度超过50个字符,则将主题行的颜色更改为橙​​色,如果长度超过65个字符,则将其更改为红色。 您可以在Git Integration上了解有关Atom的git集成的更多信息。

Open up your Atom’s styles.less file, which is under the “Atom” menu option:

打开您的Atom的styles.less文件,该文件位于“ Atom”菜单选项下:

Write the following lines of code into Atom’s styles.less file:

将以下代码行写入Atom的styles.less文件中:

atom-text-editor::shadow { .git-commit.invalid.deprecated.line-too-long {  color: @text-color-warning;  text-decoration: none; }
.git-commit.invalid.illegal.line-too-long {  color: @text-color-selected;  background: @background-color-error;  opacity: 0.9; }}

Once you’ve made the changes and saved the file, Atom will behave as shown in Figure 2.

进行更改并保存文件后,Atom的行为将如图2所示。

编写用于提交消息结构的代码段 (Write a snippet for commit message structure)

Second, we will write a short snippet for commit messages. This snippet will provide placeholders for subject line and body that can be navigated using TAB key.

其次,我们将为提交消息编写一个简短的代码段。 此摘要将提供主题行和正文的占位符,可以使用TAB键进行导航。

Write the following lines of code into Atom’s snippets.cson:

将以下代码行写入Atom的snippets.cson:

'.text.git-commit':  'commit-message':    'prefix': 'comm'    'body': """      ${1:Subject < 50 chars}
${2:Body in detail}    """

After you make the changes and save the snippets file, the next time you open your commit message, you just need to type comm and press TAB to expand your snippet.

进行更改并保存摘录文件后,下次打开提交消息时,只需键入comm并按TAB键即可扩展摘录。

Once the snippet has been expanded, you can press TAB again to jump the cursor from ‘subject line’ to ‘body’. Figure 3 shows this snippet in action.

扩展代码段后,您可以再次按TAB键将光标从“主题行”跳转到“正文”。 图3显示了该片段的运行情况。

These little code snippets have sure improved my git commit workflow, and I’m confident they can improve yours.

这些小代码段确实改善了我的git commit工作流程,并且我相信它们可以改善您的git commit工作流程。

If you have any other committing-related snippets that you use in Atom, please be sure to post them. I’d love to have a look and maybe incorporate them into my workflow.

如果您在Atom中使用其他任何与提交相关的摘要,请确保将其发布。 我很想看看,也许可以将它们合并到我的工作流程中。

Also — for those curious — here’s a list of themes and packages I’ve used in the above figures:

另外-对于那些好奇的人-这是我在上图中使用的主题和包的列表:

  • UI Theme — Nucleus Dark

    UI主题— 暗核

  • Syntax Theme — Atom Dark Fusion

    语法主题— Atom Dark Fusion

  • Git editing support for Atom — language-git

    对Atom的Git编辑支持— language-git

翻译自: https://www.freecodecamp.org/news/towards-better-git-commit-messages-using-atom-6dbda5e14984/

atom 中首次使用git

atom 中首次使用git_使用Atom获得更好的Git提交消息相关推荐

  1. 在提交消息中链接到GitHub上的问题编号

    是否有可能在git commit消息中自动获得指向GitHub问题编号的链接? #1楼 您还可以交叉引用回购: githubuser/repository#xxx xxx是问题编号 #2楼 他们在他们 ...

  2. Atom飞行手册翻译: 2.2 在Atom中移动

    在Atom中移动 用鼠标和方向键,简单地在Atom中移来移去非常容易,然而Atom有一些快捷键,可以让你把手一直放到键盘上,更快速地浏览文档. 首先,Atom自带许多Emacs的快捷键来浏览文档.要想 ...

  3. Atom飞行手册翻译: 2.1 Atom中的包

    在我们介绍完Atom最基础的部分之后,我们要了解如何真正尽可能使用它了.在这一章中我们会介绍如何为了添加新功能而寻找并安全新的包,如何寻找并安装新的主题,如何以一种更高级的方法处理文本,如何以任何你想 ...

  4. atom配置python_在Atom中设置Python开发环境

    在使用Python开发环境中,很多人比较喜欢使用Atom.在Atom中,有很多编辑工具,包括文字,方括号,原子.Atom是完全免费的,并且它具有许多可用的程序包和主题,从而使编码变得更加容易.在这里, ...

  5. Atom飞行手册翻译: 4.4 Atom中的序列化

    Atom中的序列化 当一个窗口被刷新,或者从上一次会话恢复的时候,视图和它相关的对象会从JSON表达式中反序列化,它们在窗口上一次关闭时储存.要使你自己的视图和对象兼容刷新,你需要让它们很好地执行序列 ...

  6. Atom飞行手册翻译: 2.12 在Atom中写作

    在Atom中写作 虽然Atom通常可能用来编写软件的代码,但是它还可以用来高效地编写文章.这通常采用一些标记语言,比如说Markdown和Asciidoc(也就是英文手册所用的格式)来完成.下面我们会 ...

  7. Atom飞行手册翻译: 2.11 Atom中的版本控制

    Atom中的版本控制 对于任何项目来说,版本控制都是很重要的一个方面.Atom集成了一些基本的Git和Github功能. 检出(checkout)HEAD中的版本 cmd-alt-Z快捷键检出当前文件 ...

  8. 在Atom中运行脚本

    2019独角兽企业重金招聘Python工程师标准>>> 现在可以在atom官网(https://atom.io/)找到deb包. 插件script可以让atom运行脚本,具体请见:h ...

  9. atom运行python,atom运行python_Win10环境下Atom安装和运行Python的方法

    本文介绍了在Windows10下安装Atom和运行Python的教程.有一定的参考价值,有需要的朋友可以参考一下,希望对大家有帮助. 相关推荐:atom教程 首先,下载Atom 1.官网:Atom官网 ...

最新文章

  1. Razor视图出现重复的解决方法
  2. WPF 根据绑定值设置DataGrid行背景色
  3. 使用JDOM解析XML
  4. 每日一博 - ThreadLocal VS InheritableThreadLocal VS TransmittableThreadLocal
  5. 机器学习算法如何应用于控制_将机器学习算法应用于NBA MVP数据
  6. 一个切图仔的 CSS 笔记
  7. Windows 8 JavaScript Metro应用程序--入门(上)
  8. 一次失败的项目经理招聘经验
  9. http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=9332 多broser
  10. select下拉选择框
  11. word2019加载mathtype
  12. 云通讯赛道掀起并购潮 背后有哪些新趋势暗流涌动?
  13. Python基础知识从hello world 开始(第二天)
  14. 遗传算法优化BP神经网络,bp神经网络的优化算法
  15. springboot 整合 ueditor 并实现文件上传(自定义上传路径)
  16. Android实战——简单网络视频播放器
  17. 酒与茶--网友-心香一束著
  18. 关于语言发育迟缓的孩子
  19. Qt 5.7设置调试器
  20. 去掉字符串头尾指定字符

热门文章

  1. vanpopup 高度_解决VantUI popup 弹窗不弹出或无蒙层的问题
  2. python3 线程池源码解析_5分钟看懂系列:Python 线程池原理及实现
  3. Hyperloop 让发布简洁高效
  4. .Net中如何操作IIS(源代码)
  5. VS2005编译QT4.8.2
  6. 手动建库11.2.0.4
  7. 开源:Angularjs示例--Sonar中项目使用语言分布图
  8. FreeMarker标签介绍
  9. 64位win7安装IIS7时不能浏览asp的问题
  10. iOS开发swift版异步加载网络图片(带缓存和缺省图片)