Git

About this knowledge base

This directory is organized from the official Git cheat sheet and adds local installation guidance, usage scenarios for each command category, common risks, and more modern alternatives. Commands remain in English; the explanations are localized.

Git is a distributed version-control system. Alongside the existing command tutorials, this knowledge base provides an AI Agent Engineer learning route from zero: first build a mental model of snapshots, objects, and references; then understand the working tree, staging area, and HEAD; then learn branches, diffs, recovery, and remote collaboration; finally complete a project in an isolated experimental repository. Do not run cleanup, hard resets, history rewrites, or force pushes in a real working tree until you understand their impact.

Sources

Original page: Git Cheat Sheet; PDF: cheat-sheet.pdf; Windows installation page: Installing Git.

Command placeholders

<path>, <commit>, <branch>, and <url> in headings or inline commands mean “replace this with a real value”; do not type the angle brackets literally into PowerShell. To prevent accidental copy/paste, this course’s PowerShell blocks use parseable examples such as README.md, HEAD~1, and feature/demo. A path argument prefixed with -- makes the end of options explicit.

Where this course fits in the overall route

This course is in the Engineering Foundations stage. It builds on Markdown and command-line basics, providing reviewable and recoverable change history for later Python projects, Agent tools, evaluation assets, and production configuration. Git tracks versions only; it does not replace tests, artifact storage, secret management, or deployment approval.

Learning objectives

  • Explain the relationship among a working tree, staging area, commits, and branches.
  • Inspect status, diffs, untracked files, and sensitive-information risk before a commit.
  • Use branches to isolate Agent code, prompts, configuration, and evaluation changes.
  • Choose among restore, revert, reset, and reflog recovery approaches.
  • Synchronize remote repositories safely and understand the risk of rewriting shared history.
  • Complete an isolated-repository practice from initialization through conflict resolution, rollback, and review.

Prerequisites

The primary environment is Windows 11 with PowerShell 7. You only need to know how to change directories and edit text. It is recommended to complete Markdown first; installation and identity configuration begin in lesson 1.

Quick entry points

Hands-on work and project entry

See Version-Control Practice and Self-Check for the integrated task. All destructive exercises belong in a newly created isolated experimental repository. Preserve evidence with git status, git diff, and git log before executing a recovery command.

Mastery checklist

  • Can draw the working-tree → staging-area → commit flow and verify it with commands.
  • Before every commit, inspect staged and unstaged diffs, untracked files, and credential risk.
  • Can create a branch, create and resolve a text conflict, and explain the resulting content.
  • Can distinguish undoing uncommitted changes, creating an inverse commit, and moving a branch pointer.
  • Can recover a locally unreachable commit with reflog.
  • Do not casually rewrite shared branches; when force pushing is necessary, first understand and prefer --force-with-lease.
  • Can explain why .gitignore cannot protect credentials that have already entered history.

Relationship to other knowledge bases

Next knowledge baseConnection
MarkdownDocumentation and prompts are textual assets with readable diffs.
Python FundamentalsSource code, tests, and dependency declarations should form reproducible commits.
Linux CommandsServer-side Git operations rely on reliable command-line and path judgment.
MLOps, LLMOpsGit records code version; data, models, prompts, evaluation, and deployment need additional tracking.
Agent Skills, MCPTool contracts and configuration changes should be reviewable and reversible.

Primary references

Checked 2026-07-14. The current official stable-documentation baseline was Git 2.55.0; this machine’s available syntax was checked under Windows 11, PowerShell 7, and git version 2.54.0.windows.1. They are recorded separately: a local version is not a global latest version. Options evolve by Git version; before execution, use a focused command such as git help status to consult local documentation.