初始/第一次 git 提交内容的约定是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35103508/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:45:00  来源:igfitidea点击:

What is the convention for the content of an initial/first git commit?

git

提问by andydavies

I know that Git commits should be made for each logical change, but what is the convention (if any exist) for the first commit?

我知道应该为每个逻辑更改进行 Git 提交,但是第一次提交的约定(如果存在)是什么?

[note: I'm not inviting opinion/discussion on this - if there isn't a common convention then fine].

[注意:我不邀请对此发表意见/讨论 - 如果没有共同的约定,那很好]。

For instance I've started a website from scratch with index.html - my first 'logical change' commit could be anything from adding the <head>elements, adding the HTML structure, or adding the basic content and CSS. Or should the first commit be the first 'working' version?

例如,我使用 index.html 从头开始​​创建一个网站——我的第一个“逻辑更改”提交可以是添加<head>元素、添加 HTML 结构或添加基本内容和 CSS 的任何内容。或者第一次提交应该是第一个“工作”版本?

Edit: I don't mean the commit message; I mean the content of the files.

编辑:我不是指提交信息;我的意思是文件的内容。

采纳答案by andydavies

It seems there is no established convention then (for the content; not the message).

似乎没有既定的约定(对于内容;而不是消息)。

I found this article about best practice useful: https://sethrobertson.github.io/GitBestPractices/

我发现这篇关于最佳实践的文章很有用:https: //sethrobertson.github.io/GitBestPractices/

回答by CodeWizard

Usually the first commit is named "Initial commit".

通常第一次提交被命名为“初始提交”。

As best practice its include a READMEfile describing the project.
The READMEis usually is a md file.

作为最佳实践,它包含一个README描述项目的文件。
README通常是一个MD文件。

Just for fun read this: Funny initial git commit messages:

只是为了好玩,请阅读: 有趣的初始 git 提交消息

回答by lmiguelvargasf

As others have reported, I haven't found a standard convention, so next I will share what I usually do.

正如其他人报告的那样,我还没有找到标准约定,所以接下来我将分享我通常做的事情。

After creating the repo, I create an empty commit which message is Initial empty commit. You have to pass the option --allow-empty. Otherwise, you will get a message saying nothing to commit.

创建 repo 后,我创建了一个空提交,其消息为Initial empty commit。你必须通过选项--allow-empty。否则,您将收到一条消息,提示没有提交

$ git init # creates repository
$ git commit --allow-empty -m'Initial empty commit' # creates empty commit

I like to do it this way because it makes me think of this commit as the empty root of my repository. Besides, I can immediately push this repository without any content. After this commit I usually add the README.md.

我喜欢这样做,因为它让我认为这个提交是我存储库的空根。此外,我可以立即推送这个没有任何内容的存储库。在这次提交之后,我通常会添加 README.md。

回答by DominicEU

I'm not sure if there's any particular convention for a first commit. I always try to have at least some resemblance of a project skeleton, and likely a READMEfile describing intended purposes.

我不确定第一次提交是否有任何特定的约定。我总是尝试至少与项目骨架有一些相似之处,并且可能是一个README描述预期目的的文件。