Skip to content

Git commit

An identified Git snapshot with history and metadata: how the index selects committed content, and why a code revision alone does not reproduce a quant run.

A Git commit is an identified record that links a project snapshot to its history and descriptive metadata. In quant research, it gives a model run a precise source-code revision: a reviewer can inspect which implementation and versioned configuration produced the claim, rather than relying on a filename such as final_backtest.py.
A commit is a building block of version control. It records selected content in the local repository; creating one does not, by itself, share it with a remote server. Git's commit manual describes the ordinary workflow as recording the current index contents.

What the record contains

A commit refers to a tree, which describes the versioned project snapshot, and includes:
  • Parent commit references: the preceding history. An ordinary commit has one parent, an initial commit has none, and a merge commit has more than one.
  • Author and committer information: identities and dates. The person who originally wrote a change can differ from the person who recorded it.
  • A commit message: an explanation of the change and its purpose.
The commit's object identifier depends on its contents, including these references and metadata. Two commits can therefore describe the same project files while having different identifiers. A commit identifies a snapshot in a history; it is more than a saved file or a message saying “fixed pricing.” The Git Objects chapter explains the tree, file-content and commit objects behind this structure, while the commit-tree manual specifies the parent cases.

The version on screen may differ from the version recorded

Git separates the working tree, where files are edited, from the index, also called the staging area, which selects content for the next ordinary commit. Staging a file captures its content at that moment. Editing it again leaves a newer working version alongside the earlier staged version. Pro Git's recording-changes guide demonstrates this staged-and-unstaged state.
Suppose a fictional configuration contains a mark of 100 USD per share. The researcher stages it, then changes the working file to 110 USD per share. Recording the staged contents still captures 100. The later edit remains outside that commit.
After staging, the working file and index both contain 100 USD per share. After editing, working contains 110 while the index stays at 100. Recording the staged snapshot captures 100 and leaves working at 110.
After staging, the working file and index both contain 100 USD per share. After editing, working contains 110 while the index stays at 100. Recording the staged snapshot captures 100 and leaves working at 110.
The staged version enters the commit. Fictional mark in USD per share; a later working edit does not automatically update the index.
This small Python reference model makes the separation visible. It does not run Git, create a repository or generate a commit identifier. The copies model separate content states; they do not implement Git's object storage.
working = {"mark_usd": 100} index = working.copy() # stage this version working["mark_usd"] = 110 # later, unstaged edit recorded_snapshot = index.copy() # model an ordinary commit print("Staged:", index["mark_usd"]) print("Working:", working["mark_usd"]) print("Recorded:", recorded_snapshot["mark_usd"]) # Staged: 100 # Working: 110 # Recorded: 100
The practical review is to compare the working changes with the staged changes before recording history. In Git, git diff normally shows unstaged changes, while git diff --staged shows changes selected relative to the current commit. The distinction matters when a valuation test passed against a later working edit that the proposed commit does not contain.
This example assumes the ordinary staged-content workflow, with no path arguments or automatic staging. Options such as git commit -a, or explicit paths passed to git commit, change how content is selected; they should not be read as equivalent to recording an already reviewed index.

A source revision is one part of a run record

A commit can retain code, tests and configuration that are deliberately versioned. It does not automatically preserve an external price feed, an untracked input file, installed packages or the execution platform. Even a clean working tree does not establish that those external inputs are unchanged.

Record the source revision alongside the data snapshot and its data lineage, the run configuration, and a reproducible environment. A commit helps locate an implementation; passing tests and validating the financial assumptions remain separate tasks.
For the local inspection-and-commit cycle, the SelfMadeQuant Git lesson covers staged review and what belongs in history. The public page previews the lesson; the full lesson requires membership.

Sources

Last updated
  • git
  • version control
  • reproducibility
  • quant software
← Back to the glossaryBack to top ↑