Commit
- Standard term
A commit is a saved snapshot of a project in Git, a version-tracking tool. It records the file versions you chose to include, the previous commit, its author, and a message describing the change.
Git gives each commit an ID computed from its contents, which include the ID of the commit before it. So the commits form a chain back to the first one, and altering an old commit changes every ID after it.
Where you’ll meet it
In one session, your coding agent adds a shopping list to your meal-planner app, renames some menus, and changes how servings are calculated, all in a single commit. A week later you find the serving math is wrong.
What to do
Ask the agent to undo only the serving-math lines from that commit and leave the rest. Git can do that, though it takes more care than undoing a whole commit. From then on, have it commit each change on its own, with a message saying what the app now does.
Easy to mix up
Saving a file keeps its latest edits, and many apps save on their own. A commit is a deliberate step, and Git keeps that version of the project so you can return to it.
Check yourself
You commit a settings file that contains your email password. The next day, another commit deletes the file. Is the password still in the project?
Go deeperUndoing a commit can add to the history or rewrite it
Linus Torvalds wrote Git in 2005 to manage development of the Linux kernel. Before a commit, you pick which changes go into a staging area, a list of what the next commit will include, so one file's edits can be split across separate commits.
Undoing a commit usually means a revert, which adds a new commit that reverses the old one, so every earlier commit stays in the history. Amending or rebasing instead swaps old commits for new ones with new IDs, which causes trouble once other people hold copies of the old ones, because their history and yours no longer match.