git git中提交命令的确切含义是什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43970559/
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 12:45:34  来源:igfitidea点击:

What is exactly meaning of commit command in git

gitgithubgit-commit

提问by Pratik pound

commit is

提交是

A commit, or "revision", is an individual change to a file (or set of files). It's like when you save a file, except with Git, every time you save it creates a unique ID (a.k.a. the "SHA" or "hash") that allows you to keep record of what changes were made when and by who. Commits usually contain a commit message which is a brief description of what changes were made.

提交或“修订”是对文件(或文件集)的单独更改。这就像当你保存一个文件时,除了使用 Git,每次你保存它时都会创建一个唯一的 ID(也称为“SHA”或“hash”),它允许你记录何时以及由谁进行了哪些更改。提交通常包含提交消息,它是对所做更改的简要描述。

but i didn't got it

但我没有得到

What is exactly meaning of commitin git and git hub?

commit在 git 和 git hub 中的确切含义是什么?

NOTE:-This not dupli of any Q I am clear about git push

注意:-这不是任何 QI 的重复git push

回答by Moshe Harush

After you do changes in your code you will do "commit".

更改代码后,您将执行“提交”。

Commit set a message about the changes you were done. The commit also saves a revision of the code and you can revert the code to any version anytime in one click.

提交设置有关您已完成更改的消息。提交还会保存代码的修订版本,您可以随时单击将代码恢复到任何版本。

All time the perfect example for this is like a tree. Source tree for more precisely. This will be the perfect to explain the git branchon the source tree:

一直以来,这方面的完美例子就像一棵树。源树更准确。这将是解释源代码树上的git 分支的完美方式:

Git Sourcetree

Git 源码树

Evry commit its a point on the "master", the master will be the tree trunk.

每次在“主人”上提交一个点,主人将是树干。

You can add a branch to the tree and add more commit only on this branch. After the changes, you can merge the change to the master.

您可以向树添加一个分支,并仅在此分支上添加更多提交。更改后,您可以将更改合并到母版。

So in summary, git is used as a code version manager. Knows how to deal with conflicts and combine several different versions into one version.

所以综上所述,git是作为代码版本管理器使用的。知道如何处理冲突并将多个不同版本合并为一个版本。

And this is screen capture of comparing two different code versions (commits)

这是比较两个不同代码版本(提交)的屏幕截图

comparing two different commits on PhpStorm IDE

比较 PhpStorm IDE 上的两个不同提交

Hope I helped you :)

希望我能帮到你 :)

回答by whackamadoodle3000

A commit is where you change a 1 or more files in git. It keeps track of the changes made between each commit.

提交是您在 git 中更改 1 个或多个文件的地方。它跟踪每次提交之间所做的更改。

回答by Loren Rosen

(Yes, old question. But to help web searchers...)

(是的,老问题。但为了帮助网络搜索者......)

One possible point of confusion is that, in git lingo, 'commit' is both a noun and a verb. From its glossary

一个可能的混淆点是,在 git 术语中,“commit”既是名词又是动词。从它的词汇表

As a noun: A single point in the Git history; the entire history of a project is represented as a set of interrelated commits. The word "commit" is often used by Git in the same places other revision control systems use the words "revision" or "version". Also used as a short hand for commit object.

As a verb: The action of storing a new snapshot of the project's state in the Git history, by creating a new commit representing the current state of the index and advancing HEAD to point at the new commit.

作为名词:Git 历史上的一个点;一个项目的整个历史被表示为一组相互关联的提交。Git 经常在其他版本控制系统使用“revision”或“version”的地方使用“commit”这个词。也用作提交对象的简写。

作为动词:在 Git 历史记录中存储项目状态的新快照的操作,通过创建表示索引当前状态的新提交并将 HEAD 前进以指向新提交。

(See https://git-scm.com/docs/gitglossary)

(见https://git-scm.com/docs/gitglossary

回答by Simon Clewer

A commit is kind of 'object' in git, and identifies and specifies a 'snapshot' of the branch at the time of the commit.

提交是 git 中的一种“对象”,它在提交时标识并指定分支的“快照”。

an object is a file stored under .git/objects

对象是存储在 .git/objects 下的文件

eg: object e6f53bc19b182fed6cd580329747f93393504389 is a file stored at .git/objects/e6/f53bc19b182fed6cd580329747f93393504389

例如:对象 e6f53bc19b182fed6cd580329747f93393504389 是存储在 .git/objects/e6/f53bc19b182fed6cd580329747f93393504389 的文件

If the object is a commit, it records other objects that together specify the commit 'snapshot'.

如果对象是提交,它会记录一起指定提交“快照”的其他对象。

Typically, the 'other objects' recorded in a commit is just two other objects - the parent commit of the current commit and the 'tree' object that specifies the actual files.

通常,提交中记录的“其他对象”只是两个其他对象 - 当前提交的父提交和指定实际文件的“树”对象。

You can examine an object thus

你可以这样检查一个对象

$ git cat-file -p e6f53bc19b182fed6cd580329747f93393504389
tree 7cb95c95270b3f28a3cb6e2107f89dc7e950d93e
parent 507dbda38d769e8c69b3701cbd21a40b3a39206e
author xx <[email protected]> 1578053251 +0000
committer xx <[email protected]> 1578053251 +0000

my big commit message here!

That's it. A commit is a file stored in .git/objects that specifies a snapshot. It contains one or more references to the parent commits and a reference to a tree object.

就是这样。提交是存储在 .git/objects 中的文件,用于指定快照。它包含一个或多个对父提交的引用和一个对树对象的引用。

There are 3 types of 'git object'

有 3 种类型的“git 对象”

commit object: contains reference to commit objects and tree objects

提交对象:包含对提交对象和树对象的引用

tree object: contains references to 'blob' objects and tree objects

树对象:包含对“blob”对象和树对象的引用

blob object: contains the file contents, a blob object usually represents a whole file.

blob 对象:包含文件内容,一个 blob 对象通常代表整个文件。