Cram Sheet333 words
Topic 2.2 — Managing repositories — cram sheet
Topic 2.2 — Managing repositories · cram sheet
Large files
| Content | Store in |
|---|---|
| Source | Git |
| Dependencies | Azure Artifacts |
| Large binaries that change often | Git LFS |
- Binaries don't delta well → near-full copy per version, paid by every clone forever.
- LFS stores a pointer; content lives outside, fetched on checkout.
- Enabling LFS does not shrink existing history — that needs a rewrite.
Scaling
- Scalar: partial clone (contents on demand) + sparse checkout (only your directories) + background maintenance.
- Cross-repo sharing: prefer a package feed over submodules. A submodule is a commit pointer with no version semantics.
- Split or not? Does the code change together? Ships together → lives together.
Permissions
- Levels: organisation → project → repository → branch.
- Deny beats Allow; Not set = inherit.
- Permissions = who may act. Policies = what must be true. Both needed — policy alone leaves force push available.
- Assign Force push and Manage permissions deliberately.
Tags
- Annotated for releases — tagger, date, message, and signable.
- A release tag is the rollback and hotfix branch point.
- Tags can move. Never move one — every prior reference silently changes meaning.
Recovery
| Situation | Command |
|---|---|
| Lost commit after reset/rebase | git reflog → checkout/reset |
| Deleted branch | git reflog → git branch |
| One commit from elsewhere | git cherry-pick |
| Undo a pushed commit | git revert |
| Restore a deleted file | git restore --source=<commit> |
Reflog is local and expires — it cannot recover a colleague's commits.
Removing data
git rm+ commit removes from the current tree only.- A committed secret: rotate first. Removal is secondary — the value is already distributed.
git filter-repo/ BFG rewrite history → every hash changes, everyone re-clones.- Prevention: push protection,
.gitignore, pre-commit hooks.