Git Workflow

lesson workflow active workflow/git-workflow.md View on GitHub

Git Workflow

Rule

Stage only intended files explicitly, never use git add . or git commit -a, and commit trivial docs/journal directly to master while using branches/PRs for non-trivial changes.

Context

When committing changes via git.

Detection

Observable signals that indicate need for proper git workflow:

Pattern

Follow this step-by-step workflow:

1) Decide scope

2) Prepare working tree

3) Verify branch (prevents accidental master commits)

4) Commit with explicit paths

Example correct workflows:

# Check what changed (shows tracked vs untracked)
git status

# Verify on correct branch
git branch --show-current  # Should show feature-branch, not master

# Tracked files: Commit directly
git commit tasks/existing-task.md lessons/workflow/some-lesson.md -m "docs: update task and lesson"

# Untracked files: Add then commit (explicit in both!)
git add journal/2025-11-06-topic.md && git commit journal/2025-11-06-topic.md -m "docs(journal): session summary"
git add people/new-person.md && git commit people/new-person.md -m "docs(people): add profile"

# Mixed (untracked + tracked): Add untracked files, then commit all explicitly
git add journal/2025-11-06-topic.md && git commit journal/2025-11-06-topic.md tasks/existing-task.md -m "docs: session work"

# If pre-commit fails, run the entire `git commit` command again (don't amend)

Recovery from accidental master commit:

# If you committed to master by accident:
git branch feature-branch    # Create branch at current HEAD
git reset --hard HEAD~1      # Move master back one commit
git checkout feature-branch  # Switch to feature branch
# Now you're on feature-branch with your commit, master is clean

5) Submodules (when applicable)

6) Push/PR

Outcome

Following this pattern results in:

Related

Origin

Established 2025-08-08 from user/agent session to reduce review overhead and PR noise.

Match Keywords

never use git add . or git commit -a stage only intended files explicitly commit trivial docs directly to master accidental staging of unintended files submodule update sequence committed to master by accident