liveBook · Manning

Commit

As explained in Software Engineering for Data Scientists

A commit is a recorded set of code changes saved in Git’s version history with an associated message.

A commit records a snapshot of code changes in Git’s version history and attaches a short message describing those changes. Before committing, Git stages files with git add; afterward, the snapshot can be pushed to a remote repository for others to access. section 2.3 section 2.3.2

A practical commit workflow is:

  • Run git status to find created or modified files that are not yet committed. section 2.3.2
  • Run git add . for all changed files, or git add [file_name] for a specific file, placing changes in Git’s staging area. section 2.3 section 2.3.2
  • Run git commit -m "message" to save the staged changes as a snapshot with a description. section 2.3
  • Run git push to submit the local commit to a remote repository so collaborators can download or view it. section 2.3.2

Each commit has a unique hash ID. Use git log to list commits and git show followed by a hash to inspect the commit’s code changes. section 2.3.3 section 2.3.3

Commit a data-processing script

After creating 1_process_data.py, check its status, stage it, and save it with a descriptive message: git status; git add 1_process_data.py; git commit -m "create 1_process_data.py for processing data". Push the commit afterward when collaborators need the updated codebase. section 2.3.2 section 2.3.2

Listing 2.7 git commit saves the changes you’ve made as a snapshot of the repo. The parameter -m is used to include a message / description for the commit.
git commit -m "upload initial set of files" #1

See the complete git commit command, including the -m parameter for recording a snapshot description. section 2.3

How Software Engineering for Data Scientists covers it

How deep it goes
Defines snapshots, messages, hashes, staging, and inspection commands, while deferring detailed branch mechanics.
Examples
Uses a new Python data-processing script, status output, commit messages, hash IDs, and displayed diffs as concrete examples.
What it assumes
Assumes a working directory and Git command access while teaching initialization, staging, committing, and inspection from zero.
What you can do after
Operate/configure Git by staging files, creating descriptive commits, publishing them, and inspecting their history and contents.
How it connects
Connects version control, staging areas, remote repositories, git push, git log, and git show.

Also explained in

Compare how 8 books explain commit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Engineering for Data Scientists. The section links point to the parts of the book it draws on.