Cyber Intelligence
Source Control Strategy · 10-15% of exam

L6. Repository Management: Git LFS, Scalar & Repository Scaling

Keep large binaries out of Git history with LFS, keep huge monorepos fast to clone with Scalar, and know how to recover or permanently remove data from source control.

Git Large File Storage: Keeping Binaries Out of History

Git Large File Storage (LFS) solves a common problem: binary files (images, videos, compiled libraries) bloat repository history. Every clone and fetch downloads the entire history, so adding a large binary means every developer waits longer and uses more disk.

Git LFS replaces large files with lightweight pointer files (a few hundred bytes) in the repository itself. The actual file content is stored separately in a content-addressable storage system. When a developer checks out a file, Git LFS automatically fetches the actual binary from storage.

This keeps clone and fetch operations fast while still versioning binary assets. It is essential for teams with lots of media content or compiled artifacts.

Scalar: Monorepos at Scale

Some organizations run monorepos: a single repository containing code, tests, and configuration for an entire company or product line. Microsoft itself uses a monorepo with billions of files. Scalar is a Git tool built on Git's partial clone and sparse-checkout features. Instead of downloading every commit, tree, and blob in the history, Scalar downloads only the parts you actually need. If you work in the /frontend directory, you don't download the entire /backend history.

Scalar can make a repository with millions of files clone and fetch in seconds instead of hours.

Sharing Code Across Repositories

Sometimes you need to reference code from one repository inside another. Two approaches exist, each with different trade-offs:

FeatureGit SubmodulesGit Subtree
Reference TypePoints to specific commit of external repoMerges external repo history into subdirectory
HistorySeparate; external changes not includedFull history merged; duplicates external history
Clone SizeSmaller (external content fetched on demand)Larger (includes full external history)
UpdatesExplicit: must pull and commit submodule updatesAutomatic: external changes pulled into main history
ComplexityHigher: requires submodule workflow trainingLower: simpler mental model for small projects
Best Use CaseLarge shared libraries, multi-team dependenciesSmall shared code snippets, one-way integrations
Git submodules let you embed another repository as a subdirectory while keeping it logically separate. Updates to the referenced repository require explicit update steps. Git subtree merges another repository's history directly into a subdirectory. The history becomes part of your repository, so future clones include both histories. Subtree is simpler for small shared libraries but creates duplicate history.

Repository Permissions

Azure Repos supports branch-level and repository-level permissions tied to security groups. You can restrict who can merge to main, who can push to release branches, and who can delete branches. GitHub uses team roles: read (view), triage (manage issues/PRs), write (push), maintain (manage settings), and admin (full control). Permissions are assigned per repository and inherited by team members.

Tags for Release Management

Annotated tags are full objects with author, date, and message. They are ideal for releases: they document why this version was released and by whom. Lightweight tags are just pointers to a commit, useful for internal markers.

Most teams tag releases with annotated tags and configure release pipelines to trigger from tag creation. A tag like v1.2.3 signals a release point that is semantically versioned and release-ready.

Recovering Lost Commits

Accidentally running git reset --hard is terrifying, but git reflog records everywhere your branch pointers have pointed. If you haven't garbage-collected yet, git reflog can recover a "lost" commit.

git reflog
git show <lost-commit-hash>
git branch recover-branch <commit-hash>

This is a lifeline if you accidentally delete a branch or hard-reset past commits.

Removing Secrets from History

If you commit a secret (API key, password, database credential) and push it, simply deleting the file in a new commit is not enough. The secret still exists in the commit history where anyone with repository access can find it. git filter-repo (the modern recommended tool, replacing the older git filter-branch) rewrites history to remove the secret from every commit. After filtering, you must force-push and rotate the leaked credential immediately. Exam tip: The AZ-400 exam tests Git LFS for binaries, Scalar for monorepos, git reflog for recovery, and git filter-repo for removing secrets. Know the right tool for each scenario.

Exam Focus Points
  • Git LFS replaces large binary files with lightweight pointers in the repository, storing the actual content separately, which keeps clone and fetch operations fast
  • Scalar (built on Git's partial clone and sparse-checkout) is designed to make working with very large monorepos practical by only fetching the commits, trees, and blobs actually needed
  • git submodules reference a specific commit of another repository as a subdirectory, while git subtree merges another repository's history directly into a subdirectory of the current one
  • git reflog can recover commits that appear lost after a hard reset or branch deletion, as long as they have not been garbage collected yet
  • git filter-repo (the modern recommended tool, superseding git filter-branch) or BFG Repo-Cleaner are used to rewrite history and permanently remove an accidentally committed secret or large file from source control
Knowledge Check

1. A repository has grown to include years of large binary asset files, making every clone extremely slow. Which tool is designed specifically to keep large binaries out of the normal Git object history while still versioning them?

2. A developer accidentally ran git reset --hard and lost commits that had not been pushed anywhere. What is the first thing they should try to recover the lost work?

3. A secret credential was accidentally committed and pushed to a shared repository weeks ago. Simply deleting the file in a new commit does not remove it from history. What is the correct way to permanently remove it?

Recommended: Pluralsight

This free course covers the theory. Pluralsight adds structured DevOps Engineer Expert learning paths, hands-on Azure Pipelines and GitHub Actions labs, and timed practice exams to make it stick before exam day.

Start AZ-400 prep free10-day free trial available