问题
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.
but i didn't got it
What is exactly meaning of commit
in git and git hub?
NOTE:-This not dupli of any Q I am clear about git push
回答1:
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 branch on the source tree:
Every 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.
And this is screen capture of comparing two different code versions (commits)
Hope I helped you :)
回答2:
A commit is kind of 'object' in git, and identifies and specifies a 'snapshot' of the branch at the time of the commit.
an object is a file stored under .git/objects
eg: object e6f53bc19b182fed6cd580329747f93393504389 is a file stored at .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 <xx@xx.com> 1578053251 +0000
committer xx <xx@xx.com> 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.
There are 3 types of 'git object'
commit object: contains reference to commit objects and tree objects
tree object: contains references to 'blob' objects and tree objects
blob object: contains the file contents, a blob object usually represents a whole file.
回答3:
(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
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.
(See https://git-scm.com/docs/gitglossary)
回答4:
A commit is where you change a 1 or more files in git. It keeps track of the changes made between each commit.
来源:https://stackoverflow.com/questions/43970559/what-is-exactly-meaning-of-commit-command-in-git