🌐
Git
git-scm.com › docs › git-commit
Git - git-commit Documentation
Create a new commit containing the current contents of the index and the given log message describing the changes. The new commit is a direct child of HEAD, usually the tip of the current branch, and the branch is updated to point to it (unless no branch is associated with the working tree, in which case HEAD is "detached" as described in git-checkout[1]).
🌐
W3Schools
w3schools.com › git › git_commit.asp
Git Commit
This commits all modified and deleted files, but not new/untracked files. git commit -a -m "Quick update to README" [master 123abcd] Quick update to README 1 file changed, 2 insertions(+)
🌐
GitLab
docs.gitlab.com › tutorials › make_first_git_commit
Tutorial: Make your first Git commit | GitLab Docs
When you work in a Git repository, you work in branches. By default, the contents of a repository are in a default branch. To make changes, you: Create your own branch, which is a snapshot of the default branch at the time you create it. Make changes and push them to your branch. Each push creates a commit...
🌐
GitHub
github.com › git-guides › git-commit
Git Guides - git commit · GitHub
You can make commits to different branches, and specify exactly what changes you want to include. Commits are created on the branch that you've currently checked out to (wherever HEAD is pointing) so it's always a good idea to run git status before making a commit, to check that you're checked out to the branch that you intend to be.
🌐
Atlassian
atlassian.com › git › tutorials › saving-changes › git-commit
Git Commit | Atlassian Git Tutorial
At a high-level, Git can be thought of as a timeline management utility. Commits are the core building block units of a Git project timeline. Commits can be thought of as snapshots or milestones along the timeline of a Git project. Commits are created with the git commit command to capture the state of a project at that point in time.
🌐
GitKraken
gitkraken.com › home › learn › learn git: commit
Git Commit - How to Git Commit | Learn Git
March 24, 2021 - Learn how to Git commit in the CLI, including how to add a Git commit message and how to amend a commit. Then, see how to revert a commit with the GitKraken Git GUI.
🌐
Git Tower
git-tower.com › learn › git › commands › git-commit
git commit - Saving changes to the local repository | Learn Version Control with Git
The "commit" command is used to save your changes to the local repository. Note that you have to explicitly tell Git which changes you want to include in a commit before running the "git commit" command.
🌐
Linux Kernel
kernel.org › pub › software › scm › git › docs › git-commit.html
git-commit(1) Manual Page
November 24, 2025 - Create a new commit containing the current contents of the index and the given log message describing the changes. The new commit is a direct child of HEAD, usually the tip of the current branch, and the branch is updated to point to it (unless no branch is associated with the working tree, in which case HEAD is "detached" as described in git-checkout(1)).
🌐
GeeksforGeeks
geeksforgeeks.org › git › what-is-git-commit
Git Commit - GeeksforGeeks
February 27, 2026 - Allows you to commit changes hunk by hunk, giving fine-grained control over commits. ... Working with Git Commit explains how commits are created, customized, viewed, amended, and managed in a Git workflow.
Find elsewhere
🌐
CloudBees
cloudbees.com › blog › git-commit-detailed-tutorial-on-saving-your-code
Git Commit: A Detailed Tutorial on Saving Your Code
First, run the following commands to create and commit a second file: Great. Your repository now has two files. Let’s now change the first file: ... Now your two files are edited, and you can verify that by using the git status command.
Top answer
1 of 3
3
  • since git uses a system of "snapshots" of the entire codebase, git needs to know history of changes and show to all coders who did what at each moment in time.

It's a reasonable way to phrase it.

  • "commit" is like recording the changes in project's memory.

Yes, committing is adding a record of your changes (compared to the previous commit) on top of the branch.

  • uploading my changed version of the project,i.e. my branch to main online repo(master) is a different thing?

When you push, the remote server appends your changes to the remote branch provided that your history follows the server history. For example, if anyone has appended any change to the server history before you push, you are both showing divergent versions of the history from a certain point. So you need first to rewrite your local history so that it complies with the server's history. (usually using git pull, which will merge or rebase your branch depending on your choice)

  • when I upload my local changes to the main version of the project, my commits(recorded in .git file) become known to others.

Yes, when you push you let other know how you modified the history.

  • uploading changes to master branch is "pushing" all my commits, right?

Pushing is "uploading" (if you wish to use that word) your changes to the remote's master branch. As I said earlier, the remote will only accept if your changes are built upon the latest history available at the remote's master.

Note that all of this is true for any branch, you can have as many branches as you want, no only master.

2 of 3
2

git basically uses these 3 things to store your data:

  • A blob is just a binary blob of stuff (your source code, an image, whatever). The blob does not contain information about the type or name of the content and is just a mass of bytes.
  • A tree points to one or more blobs, think "directory". It contains file names etc. of the blobs it points to.
  • A commit (the data object, not the git command) is a separate entity that points to exactly one tree (the state of all files at that point in time) and zero or more other commits (the parent(s), which may be missing for the very first commit in a repository, and which may be multiple in case of merges).

That's it. There's nothing else to it, conceptionally. In practice, there are branches and tags, but these are just special "sticky notes" pointing to commits. There are also mechanisms in place to reduce storage and such, but they are not of interest unless you hack on the code or go real deep.

Answering your question is easy in this context:

  • When you checkout a commit into your working directory, you get the files from one specific commit. Say, the sticky note (branch) master points to a commit afd876123, and you clone the repository into a fresh working directory, then you get the files represented in the tree that the commit afd876123 points to.
  • git of course keeps track and creates a special sticky note HEAD which stores the information that you are on master and on commit afd876123. It also creates an index which you can think of as an anonymous tree.
  • You edit some files in your working directory.
  • When you run git add, then git updates the index with your changes. While internally it works differently, you can think of it as updating the tree "index" with your changes.
  • No commit is associated with this tree (yet), so it is not a permanent thing; it does not affect pushes, pulls or whatever.
  • When you run git commit it creates a new commit object which points to the tree that is represented by your current index, as well as the previous commit afd876123 and other information (like timestamp, log message...). This commit object is then added to the data store and thus finalized.

The rest of your assumptions about push/pull are basically correct.

🌐
GitHub
gist.github.com › luismts › 495d982e8c5b1a0ced4a57cf3d93cf60
Git Tips and Git Commit Best Practices · GitHub
Save luismts/495d982e8c5b1a0ced4a57cf3d93cf60 to your computer and use it in GitHub Desktop. ... A commit should be a wrapper for related changes. For example, fixing two different bugs should produce two separate commits. Small commits make it easier for other developers to understand the changes and roll them back if something went wrong.
🌐
Conventional Commits
conventionalcommits.org › en › v1.0.0
Conventional Commits
A commit body is free-form and MAY consist of any number of newline separated paragraphs. One or more footers MAY be provided one blank line after the body. Each footer MUST consist of a word token, followed by either a :<space> or <space># separator, followed by a string value (this is inspired by the git trailer convention).
🌐
Microsoft Learn
learn.microsoft.com › en-us › visualstudio › version-control › git-make-commit
Make a Git commit in Visual Studio | Microsoft Learn
3 weeks ago - Git tracks file changes in your repo as you work, and separates the files in your repo into three categories. These changes are equivalent to what you would see when you enter the git status command in the command line: Unmodified files: These files haven't changed since your last commit.
🌐
Git
git-scm.com › docs › gittutorial › 2.8.6
Git - gittutorial Documentation
If you need to make any further adjustments, do so now, and then add any newly modified content to the index. Finally, commit your changes with: ... This will again prompt you for a message describing the change, and then record a new version of the project. Alternatively, instead of running git ...
🌐
Linux Man Pages
linux.die.net › man › 1 › git-commit
git-commit(1): Record changes to repository - Linux man page
Tell the command to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected. ... Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.
🌐
GitKraken
gitkraken.com › home › learn › tutorials › learn git: how to git commit
How to Git Commit | Beginner Git Tutorial
May 26, 2021 - How do you perform a Git commit? When you modify, add, delete, or rename a file in your local working directory, it is not immediately stored to your repository.
🌐
DataCamp
datacamp.com › tutorial › git-commit
Git Commit Tutorial: How to Track and Document Code Changes | DataCamp
March 25, 2025 - One of the most fundamental building blocks of version control in Git is the git commit command. A git commit captures a snapshot of the current state of your staged files and saves them to the repository’s history.
🌐
Career Karma
careerkarma.com › blog › git › git commit
Git Commit: an important part of the Git version control system.
December 1, 2023 - The git commit command is one step in “saving” the changes made to a project to a repository. The git add command line function is first used to create a record of the changes that will be stored in a commit, then git commit is used to create ...