Managing Git repositories

AZ-400 DevOps EngineerSource control strategyAbout 20 minutesBy Cloud Hands On

Large files with Git LFS, scaling big repositories, permissions, tags, recovering lost work and removing data from history.

In this lesson you'll learn

1. Large files

Git stores every version of every file. Large binaries (videos, design files, datasets) bloat the repository and slow clones. Git LFS (Large File Storage) stores those files on a separate server and keeps small pointer files in Git. You choose file types with git lfs track "*.psd", which writes to .gitattributes. Both GitHub and Azure Repos support LFS. git-fat is an older tool with the same idea, storing large files on a server of your choice.

2. Scaling and sharing

For very large repositories, Scalar (now part of Git) turns on performance features: partial clone, sparse checkout, background maintenance and the file system monitor. Shallow clones (--depth) help pipelines that only need recent history.

To share code across repositories, prefer packages (versioned, published to a feed). Git submodules embed another repository at a fixed commit; they work but add friction. Some organisations choose a monorepo for easier cross-project changes, at the cost of needing these scaling tools.

3. Permissions and tags

In Azure Repos, permissions such as Contribute, Create branch, Force push and Bypass policies are set per repository or per branch, for groups such as Contributors and Readers. In GitHub, repository roles are Read, Triage, Write, Maintain and Admin, granted to people or teams.

Tags mark points in history, usually releases: lightweight tags are simple names; annotated tags (git tag -a v2.4.0 -m "...") store the tagger, date and message, and are what release tooling expects. Push them with git push origin v2.4.0 or --tags.

4. Recovering and removing data

  • Recover a lost commit or deleted branch: git reflog shows where HEAD has been; create a branch at that commit.
  • Undo a pushed commit safely: git revert adds a new commit that reverses it, without rewriting history.
  • Remove a file or secret from all history: git filter-repo (or the BFG Repo-Cleaner), then force push and have everyone re-clone.

If a secret was committed, rotate it first: once pushed, assume it's been copied. Rewriting history only stops further exposure.

Example

A Harbourline Design developer committed a storage key. The team rotated the key within minutes, used git filter-repo to remove the file from history, force pushed, and turned on secret scanning push protection so the next one is blocked before it lands.

Exam traps to remember

  • git revert is safe on shared branches; git reset rewrites history.
  • Removing a secret from history doesn't make it safe: rotate it.
  • Git LFS is configured through .gitattributes.

Test yourself: 3 check questions and exam-style practice questions on this topic are in the AZ-400 DevOps Engineer app.

Practise in the app

Keep going