Skip to content

Latest commit

 

History

History
87 lines (60 loc) · 1.69 KB

File metadata and controls

87 lines (60 loc) · 1.69 KB

Git First Repository Workflow

This note describes the smallest useful Git workflow: initialize a repository, track a file, commit it, inspect history, and understand working-tree state.

Minimal Loop

mkdir demo-repo
cd demo-repo
git init
printf "first note\n" > notes.txt
git status
git add notes.txt
git commit -m "docs: add first note"

The loop is:

  • create or edit files
  • inspect state with git status
  • stage selected changes with git add
  • record a snapshot with git commit

Inspect Repository State

git status
git status --short

Useful mental model:

  • untracked files exist in the directory but are not yet part of Git history.
  • modified files are tracked files with working-tree changes.
  • staged files are selected for the next commit.

Inspect History

git log --oneline
git show --stat

Use git log --oneline for a compact history and git show --stat to see what changed in the latest commit.

Inspect Changes

Before staging:

git diff

After staging:

git diff --cached

This distinction matters because Git commits the staged snapshot, not every file currently changed in the working tree.

Configure Identity

If Git asks for user identity:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Use repository-local configuration when you need a different identity for one repository:

git config user.name "Your Name"
git config user.email "you@example.com"

Practical Habit

Before every commit:

git status --short
git diff --cached

This catches accidental files, missing files, and unrelated changes before they become part of history.