Git for Engineers — Level by Level›Level 3 · Cheat sheet & self-check

Level 3 — Git for platforms · wrap-up

Cheat sheet & self-check

Every command from this section on one page.

07 · Repositories for infrastructure and GitOps

Hooks and scanning

pip install pre-commit && pre-commit installEnable the hooks in .pre-commit-config.yaml for this clone
pre-commit run --all-filesRun every hook on the whole repository
gitleaks detect --source . --verboseScan the repository history for secrets
gitleaks protect --stagedScan only what you're about to commit

Signing

git config --global gpg.format sshSign commits with an SSH key
git config --global user.signingkey ~/.ssh/id_ed25519.pubWhich key signs
git config --global commit.gpgsign trueSign every commit
git log --show-signature -1Check the signature on the last commit

History clean-up

git filter-repo --path secrets.env --invert-pathsRemove a file from all history (after rotating the secret)

08 · Large repos and troubleshooting

Faster clones

git clone --depth 1 <url>Only the latest commit (CI builds)
git clone --filter=blob:none <url>Partial clone: file contents fetched on demand
git sparse-checkout set apps/payments charts/Only these folders in the working tree
git lfs track "*.iso"Store large binaries outside normal Git objects
git count-objects -vHHow big the repository really is

Fix common errors

git pull --rebase && git pushPush rejected (non-fast-forward): integrate first
git switch -c rescueIn detached HEAD with new commits: keep them on a branch
ssh -vT git@github.comDebug SSH authentication step by step
git config --global core.autocrlf inputNormalise line endings on commit (Linux/macOS)
git submodule update --init --recursiveFetch submodules after cloning