Operations

Git

Bootstrapping Git on a fresh host and recovering when the per-host branch is wrong.

5 tasks

This page is a scrubbed, public-safe version of an internal AI/SI operations runbook — the command cheat-sheet a systems engineer builds up over years of running Linux servers, virtualisation hosts, firewalls, databases, certificates and Raspberry Pi devices.

It is organised into the same sections as the original workbook, one page each — reach any of them from the AI/SI Prompts menu above. Every task on this page shows three things:

The point of the AI-prompt column is to show how a pile of accumulated tribal knowledge can be turned into something an assistant can reproduce and improve on demand: you keep the intent, and let the model rewrite the mechanics for whatever host you are on today. Nothing on this page should be run without reading it first — several snippets are destructive (dd, rm -rf, postsuper -d ALL, firewall reloads).

New install

Sets the global Git identity (user name and email) on a fresh host before its first commit.

Commands
git config --global user.name "<USER>"  User name:  <USER>
git config --global user.email "<GIT_EMAIL>"  Email:  <GIT_EMAIL>
AI prompt

Generate a Bash script for the task “New install”. Parameterise the user name and email, set them with git config --global, skip any value that is already set, and print the resulting identity. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real identity — read it from the environment.

Set remote to another git server

Points the repository at a new remote, creates a branch named after the host, pushes it upstream and records the change with etckeeper.

Commands
git remote add origin https://<USER>@github.com/<ORG>/<REPO>.git  Remote repo:  https://<USER>@github.com/<ORG>/<REPO>.git
# Create branch and checkout
git switch -c $HOSTNAME  Branch Name:  $HOSTNAME
git push --set-upstream origin $HOSTNAME
etckeeper commit "root-git"
AI prompt

Generate a Bash script for the task “Set remote to another git server”. Parameterise the remote URL and branch (default $HOSTNAME); add the origin (or update it if one exists), create and switch to the branch, push it with upstream tracking, and commit via etckeeper when it is installed. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Get and view all branches

Fetches every remote branch and lists local and remote branches together.

Commands
git fetch -a && git branch -a
AI prompt

Generate a Bash script for the task “Get and view all branches”. Fetch all remotes, prune deleted branches, and list local and remote branches with the current branch highlighted and each branch’s last commit date. Comment each step and make it safe to run in any repository.

If the hostname is wrong

Recovers when the host’s branch was created under the wrong hostname: remove the origin and redo the remote and branch setup.

Commands
git remote remove origin
Then run all of the above
AI prompt

Generate a Bash script for the task “If the hostname is wrong”. Parameterise the remote URL and the correct branch name (default $HOSTNAME); remove the existing origin, re-add it, create and push the correctly named branch, and optionally delete the mis-named branch locally and on the remote after confirmation. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Verify all repos for security alerts (Dependabot)

Scans all personal GitHub repositories for open critical or high-severity Dependabot security alerts, reporting which repos have alerts enabled and their current alert counts.

Commands
gh api /user/repos --paginate -q '.[].full_name' | while read repo; do
  crit=$(gh api "/repos/$repo/dependabot/alerts?state=open&severity=critical" -q 'length' 2>/dev/null)
  high=$(gh api "/repos/$repo/dependabot/alerts?state=open&severity=high" -q 'length' 2>/dev/null)
  if [ -z "$crit" ] && [ -z "$high" ]; then
    echo "$repo: dependabot alerts not enabled/accessible"
  else
    echo "$repo: critical=${crit:-0} high=${high:-0}"
  fi
done
AI prompt

Generate a Bash script to verify all GitHub repos for david-mrai have 0 critical or high security alerts. Use gh api /user/repos --paginate to list all repos, then query each repo's Dependabot alerts API for open critical and high-severity alerts. Report which repos have alerts enabled and their current counts. Exit with status 0 if all repos have zero alerts, non-zero if any repo has critical or high alerts. Assume the user has gh CLI installed and authenticated, comment each step, and never hard-code credentials — read from environment.