Git Operations

Overview

Git version control patterns for multi-remote repositories, deployment triggers, and professional commit workflows.

Multi-Remote Repository Pattern

The domus-* ecosystem uses three remotes for redundancy:

origin  → GitHub (primary, CI/CD triggers)
gitlab  → GitLab (backup)
gitea   → Gitea (self-hosted backup)

Push to All Remotes

git remote | xargs -I {} git push {} main

Verify All Remotes

git remote -v

Antora Hub-Spoke Deployment Trigger

The domus-docs architecture uses a hub-and-spoke model where pushing to a spoke repo (domus-captures, domus-linux-ops, etc.) does NOT trigger deployment. Only the hub (domus-docs) triggers Cloudflare Pages builds.

Manual Rebuild Trigger

cd /home/evanusmodestus/atelier/_bibliotheca/domus-docs && \
  git commit --allow-empty -m "chore: trigger rebuild for spoke updates" && \
  git remote | xargs -I {} git push {} main

Why This Is Required

Hub (domus-docs)              Cloudflare Pages
       │                            │
       └── push triggers ──────────►│ Build runs
                                     │
Spokes (domus-*-ops)                │
       │                            │
       └── push does NOT trigger ──►│ No build

The Cloudflare Pages webhook only watches the domus-docs repository. Spoke changes require an explicit hub push to aggregate.

Heredoc Commit Pattern

User’s preferred commit style for multi-line messages:

Using gach (git add + commit heredoc)

gach << 'EOF'
docs(secrets): Convert markdown to AsciiDoc format

- Converted 2025-SEC-001-Reference.md to .adoc
- Converted 2025-SEC-002-Complete-Architecture.md to .adoc
- Standardized on AsciiDoc across domus-secrets-ops
EOF

Using gacp (git add + commit + push heredoc)

gacp << 'EOF'
fix(auth): Correct RADIUS shared secret handling

- Fixed base64 encoding mismatch
- Updated ISE configuration to match
EOF

Zsh Function Definitions

Add to ~/.zshrc:

# Git ADD + commit with heredoc
gach() {
    git add -A && git commit -m "$(cat)"
}

# Git ADD + commit + push with heredoc
gacp() {
    git add -A && git commit -m "$(cat)" && git push
}

Git Aliases

Add to ~/.gitconfig:

[alias]
    ac = "!git add -A && git commit -m"
    acp = "!f() { git add -A && git commit -m \"$1\" && git push; }; f"
    st = status -sb
    lg = log --oneline --graph --decorate -20
    last = log -1 --stat
    unstage = reset HEAD --
    amend = commit --amend --no-edit

Usage

# Quick commit
git ac "fix: correct typo in config"

# Add, commit, push in one command
git acp "feat: add new endpoint"

# Short status
git st

# Pretty log
git lg

Branch Operations

Create Feature Branch

git checkout -b feature/ipsk-saml-integration

Push New Branch to All Remotes

git remote | xargs -I {} git push -u {} feature/ipsk-saml-integration

Delete Branch from All Remotes

git remote | xargs -I {} git push {} --delete feature/old-branch

Stash Operations

# Stash with message
git stash push -m "WIP: ISE policy changes"

# List stashes
git stash list

# Apply and drop
git stash pop

# Apply specific stash
git stash apply stash@{2}

# Show stash contents
git stash show -p stash@{0}

Recovering from Mistakes

Undo Last Commit (Keep Changes)

git reset --soft HEAD~1

Undo Last Commit (Discard Changes)

git reset --hard HEAD~1

Recover Deleted Branch

# Find the commit
git reflog

# Recreate branch
git checkout -b recovered-branch <commit-hash>

Revert a Pushed Commit

git revert <commit-hash>
git push

Viewing History

Commits by Author

git log --author="Evan" --oneline -20

Commits Touching a File

git log --follow -p -- path/to/file.adoc

Find When Line Was Added

git log -S "specific string" --oneline

Blame with Line Range

git blame -L 50,60 path/to/file.adoc

SSH Agent for Git

WSL requires SSH agent running for git over SSH:

Check Agent Status

ssh-add -l

Start Agent (if needed)

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Platform-Aware Auto-Start (zsh)

Add to ~/.zshrc:

# SSH agent: systemd socket (native) or manual (WSL)
if [[ -S "$XDG_RUNTIME_DIR/ssh-agent.socket" ]]; then
    export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
elif [[ -z "$SSH_AUTH_SOCK" || ! -S "$SSH_AUTH_SOCK" ]]; then
    eval "$(ssh-agent -s)" > /dev/null
    ssh-add ~/.ssh/id_ed25519 2>/dev/null
fi