The git commit
command is used to save changes to the local repository. It captures a snapshot of the projects currently staged changes, which can be thought of as "safe" versions of a project. Commits are the core building block units of a Git project timeline, and can be thought of as snapshots or milestones along the timeline of a Git project.
Before executing git commit
, the git add
command is used to promote or "stage" changes to the project that will be stored in a commit. Commits can be created with a commit message, which is a brief description of what changes were made. By default, git commit
will open up the locally configured text editor and prompt for a commit message to be entered. Passing the -m
option will forgo the text editor prompt in favor of a shortcut command that immediately creates a commit with a passed commit message.
Its important to note that git commit
is not the same as svn commit
. In SVN, a commit pushes changes from the local SVN client to a remote centralized shared SVN repository. In Git, repositories are distributed, and snapshots are committed to the local repository, which requires no interaction with other Git repositories. Git commits can later be pushed to arbitrary remote repositories.
In summary, git commit
is a command used to save changes to the local repository. It captures a snapshot of the projects currently staged changes and can be thought of as a "safe" version of a project. Commits are the core building block units of a Git project timeline and can be created with a commit message.