Study guide

4.2 LFS History Migration, git-fat & File Locking

Microsoft Certified: Azure DevOps Engineer Expert AZ-400

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: Flow of Work, Traceability & Work Tracking

1.1 Flow of Work, GitHub Flow & Feedback Cycles 1.2 Work Tracking with Azure Boards & GitHub Projects 1.3 End-to-End DevOps Traceability & Quality Tracking

2 Chapter 2: DevOps Metrics, Dashboards & Team Collaboration

2.1 DORA Metrics, Flow Metrics & Dashboard Design 2.2 Lifecycle Metrics Across the Six DevOps Phases 2.3 Work Item Queries, WIQL Charts & Analytics 2.4 Project Documentation: Wikis, Mermaid Diagrams & Release Notes 2.5 Webhooks, Service Hooks & Microsoft Teams ChatOps

3 Chapter 3: Git Branching Strategies & Pull Request Workflows

3.1 Git Branching Models & Strategy Design 3.2 Pull Request Workflows & Merge Strategies 3.3 Branch Policies, Quality Gates & Compliance Restrictions

4 Chapter 4: Repository Management, Optimization & Git Data Operations

4.1 Git LFS Architecture & .gitattributes Tracking 4.2 LFS History Migration, git-fat & File Locking 4.3 Git Repository Scaling, Scalar & Monorepo Governance 4.4 Repository Permissions & Git Tag Governance 4.5 Git Data Recovery & Sensitive-Data Scrubbing

5 Chapter 5: Package Management & Dependency Versioning

5.1 Selecting Package Tools: Azure Artifacts vs. GitHub Packages 5.2 Feed Scoping, Upstream Sources & Pipeline Authentication 5.3 Package Views, Immutability & Quality Promotion 5.4 Dependency Versioning: SemVer, CalVer & Automated Versioning 5.5 Pipeline Artifact Versioning & Artifact Storage Strategy

6 Chapter 6: Pipeline Infrastructure, Agents & Integration

6.1 Selecting a CI/CD Solution: Azure Pipelines vs. GitHub Actions 6.2 GitHub-Azure Pipelines Integration & Hybrid Migration 6.3 Hosted vs. Self-Hosted Agents & Runners 6.4 VMSS Elastic Pools, Container Jobs & Agent Governance 6.5 Pipeline Triggers, Filters & Concurrency Management

7 Chapter 7: YAML Pipeline Architecture & Reusable Elements

7.1 YAML Pipeline Anatomy: Stages, Jobs, Steps & Workspaces 7.2 Job Execution Order: DAG Dependencies, Parallelism & Conditions 7.3 Reusable Elements: Templates, Parameters & Variables 7.4 Variable Groups, Secret Variables & Key Vault Linking 7.5 YAML Environments, Checks & Deployment Approvals

8 Chapter 8: Testing Strategy, Quality Gates & Code Coverage

8.1 Test Strategy Design: Local, Unit & Integration Testing 8.2 Load, Stress & Performance Testing in Pipelines 8.3 Test Execution Tasks, Agents & Results Integration 8.4 Code Coverage Analysis & SonarQube Integration 8.5 Quality Gates, Release Gates & Governance Checks

9 Chapter 9: Modern Deployment Strategies & Zero-Downtime Delivery

9.1 Progressive Delivery: Blue-Green, Canary & Ring Deployments 9.2 Minimizing Downtime: Deployment Slots & Rolling Updates 9.3 Feature Flags with Azure App Configuration & Feature Manager 9.4 Designing the High-Priority Hotfix Path 9.5 Ordered Dependency Deployments, Resiliency & Rollback

10 Chapter 10: Artifact Deployment & Database DevOps

10.1 Containerized Application Delivery: ACR, AKS & Container Apps 10.2 Binary, Web App, Function & Scripted Deployments 10.3 Database DevOps: State-Based & Migration-Based Strategies

11 Chapter 11: Infrastructure as Code (IaC) & Azure Deployment Environments

11.1 Infrastructure as Code Strategy: Bicep, ARM & Terraform 11.2 Desired State Configuration & Azure Machine Configuration 11.3 Azure Deployment Environments (ADE) & Developer Self-Service

12 Chapter 12: Pipeline Maintenance, Health & Modernization

12.1 Pipeline Health, Flaky Tests & Reliability Engineering 12.2 Pipeline Optimization: Caching, Slicing & Concurrency 12.3 Artifact & Build Retention Governance 12.4 Modernizing CI/CD: Classic to YAML Migration

13 Chapter 13: Authentication, Authorization & Identity Governance

13.1 Microsoft Entra Service Principals & Managed Identities 13.2 Service Connections, Workload Identity & Personal Access Tokens 13.3 Azure DevOps Projects, Teams & Permission Evaluation 13.4 Access Levels, GitHub Roles & Outside Collaborators

14 Chapter 14: Secrets Management, Sensitive Data & DevSecOps Scanning

14.1 Azure Key Vault, Secret Variables & Secretless CI/CD 14.2 Security Scanning Strategy, GHAS & Secret Scanning 14.3 CodeQL SAST in Pipelines and Containers 14.4 Software Supply Chain, Container Scanning & Cloud Defender

15 Chapter 15: Telemetry Collection, Azure Monitor & Alerting

15.1 Azure Monitor Architecture, AMA & Data Collection Rules 15.2 Application Insights & Specialized Azure Monitor Insights 15.3 Alerting Rules, Action Groups & GitHub Repository Insights

16 Chapter 16: Telemetry Analysis, Distributed Tracing & SRE Practices

16.1 Distributed Tracing, Application Map & Exception Triage 16.2 KQL Log Analytics, SRE Observability & Error Budgets

4.2 LFS History Migration, git-fat & File Locking

Key Takeaways Explain This Topic AI

git lfs migrate import rewrites existing commits so historical binaries become pointers; it changes every commit SHA and therefore requires a coordinated force push.

After a history rewrite every developer and every build definition must re-clone; pulling into an old clone reintroduces the rewritten objects.

git-fat is the legacy predecessor to Git LFS, using rsync-style external storage without native Git client integration or file locking.

Files declared lockable in .gitattributes can be locked with git lfs lock, which makes the file read-only for other users and blocks their push server-side.

File locking is the standard answer for binary assets that cannot be three-way merged, such as .fbx models, .psd artwork and Office documents.

Last updated: September 2026

4.2 LFS History Migration, git-fat & File Locking

Tracking new binaries with Git LFS protects the future; it does nothing about the gigabytes already sitting in history. This section covers the history rewrite that converts an existing repository, the legacy git-fat approach it replaced, and the file locking that stops two people editing the same unmergeable binary.

Migrating Existing Repository History to Git LFS

A critical exam scenario occurs when a team already has a bloated repository where developers committed 10 GB of zip files and installers over the past three years. Simply running git lfs track "*.zip" only affects future commits . It does nothing to remove historical binary blobs embedded in past commit trees.

To remediate historical repository bloat, you must rewrite history using git lfs migrate . Historical Repository Migration Workflow:

  • Bloated History: Commit 1 (1GB .zip) ──► Commit 2 (edit) ──► Commit 3 (tip)
  • │
  • ▼ git lfs migrate import --everything
  • Cleaned History: Commit 1' (Pointer) ──► Commit 2' (Pointer) ──► Commit 3' (Tip)
  • (Commit SHAs rewritten across all branches and tags)
  • Step 1: Analyze Repository Bloat

Before modifying history, run info mode to inspect file sizes across branches: # Analyze which file extensions consume the most history space

  • git lfs migrate info --everything
  • Sample output: Listing sizes for cache: .git/objects/pack
  • *.zip 14.2 GB 120/120 files(s) 100%
  • *.onnx 5.8 GB 12/12 files(s) 100%
  • *.dll 1.1 GB 340/340 files(s) 100%
  • Step 2: Execute the History Rewrite

Run git lfs migrate import specifying the target file extensions and including all branches: # Rewrite all branches, replacing past binary blobs with LFS pointers

git lfs migrate import --include="*.zip,*.onnx,*.dll" --everything

What happens during migrate import :

Git LFS walks every commit on every local branch and tag.

When it encounters a file matching --include , it extracts the binary, computes its SHA-256 hash, stores it as an LFS object, and substitutes a pointer file in that historical commit's tree.

Because tree contents change, every downstream commit SHA is recalculated and rewritten .

.gitattributes is automatically updated and committed to track those patterns going forward.

Step 3: Force-Push Rewritten History & Coordinate Team Action

Because commit SHAs were rewritten, pushing to Azure Repos requires administrative force-push privileges: # Force-push all rewritten branches and tags

  • git push origin --force --all
  • git push origin --force --tags

Caution

Post-Migration Team Coordination: Rewriting history is a disruptive operation. All team members must be instructed to stash or commit ongoing work, delete their old local clones, and re-clone fresh from origin. If any developer attempts to run git pull from their existing local clone, Git will attempt a 3-way merge between the old history and rewritten history, resurrecting all the deleted binary blobs back into the remote repository!

Evolution: Git LFS vs. Legacy git-fat

Prior to the widespread adoption of Git LFS, early engineering teams used legacy open-source tools such as git-fat or git-annex to manage large files. Understanding the architectural divergence highlights why Git LFS is the universal enterprise standard tested on the AZ-400.

Architectural Attribute Legacy git-fat Modern Git LFS (AZ-400 Standard)

Underlying Mechanism Python script invoking rsync/rsync-over-ssh or S3 CLI Compiled Go binary native extension using Git filter protocol

Authentication Model Separate SSH keys or hardcoded cloud credentials Integrated with Git Credential Manager (GCM) , Microsoft Entra ID, and PATs

Platform Integration None (pure client-side script; server sees unknown text) Native Server Support in Azure Repos, GitHub, GitLab, and Bitbucket

File Locking Support No file locking mechanism available Native Server-Enforced File Locking ( git lfs lock )

Download Granularity Monolithic sync (fetches all files in manifest) Selective / Lazy Checkout (downloads only what is in active tree)

CI/CD Pipeline Support Requires custom Python scripts and rsync agents Native Azure Pipelines task ( checkout: self , lfs: true )

Exam Recommendation Obsolete / Legacy Anti-Pattern Official Microsoft Enterprise Standard

In modern enterprise environments, git-fat is considered technical debt. Git LFS provides standardized REST APIs, seamless credential pass-through, and granular Azure DevOps service integration.

Preventing Merge Conflicts: Git LFS File Locking

In standard software engineering, two developers can edit different functions within the same Program.cs text file simultaneously. When they merge, Git performs a 3-way text merge and combines the changes cleanly.

For binary files, a 3-way merge is mathematically impossible . Git cannot diff two versions of a Photoshop document ( .psd ), an Unreal Engine level ( .umap ), or an audio track ( .wav ). If two developers push conflicting binary edits, one developer's work must be completely discarded, leading to lost engineering hours.

Git LFS solves this through File Locking . Git LFS File Locking Workflow:

  • Developer Alice Azure Repos Server Developer Bob
  • │ │ │
  • ├─── git lfs lock design.psd ───────────────────►│ (Server marks design.psd locked) │
  • │ (Lock acquired; local file set read-write) │ │
  • │ │◄── git lfs lock design.psd ───────────┤
  • │ ├─── "Locked by Alice" (HTTP 423) ─────►│
  • │ │ (Lock rejected; file stays RO) │
  • ├─── git commit & git push ─────────────────────►│ │
  • ├─── git lfs unlock design.psd ─────────────────►│ (Lock released) │
  • Step 1: Declare Files as Lockable
  • Configure .gitattributes to mark specific binary extensions as --lockable : git lfs track "*.psd" --lockable
  • git lfs track "*.fbx" --lockable
  • git add .gitattributes && git commit -m "chore: set 3D and design assets as lockable"
  • git push origin main

When a file is designated --lockable , Git LFS automatically sets the file permissions to read-only in the local filesystem upon git checkout . This acts as an immediate physical safeguard, preventing developers from modifying the file until they acquire a server lock.

  • Step 2: The Locking Workflow # 1. Acquire an exclusive lock on the remote server
  • git lfs lock art/textures/hero.psd
  • # Output: Locked art/textures/hero.psd
  • # (Local file is automatically converted from read-only to read-write)
  • # 2. Inspect active locks across the team
  • git lfs locks

# Output:

# art/textures/hero.psd Alice ID: 104

  • # 3. Modify, commit, and push the asset
  • git add art/textures/hero.psd
  • git commit -m "feat(art): update hero texture resolution"
  • git push origin main
  • # 4. Release the lock
  • git lfs unlock art/textures/hero.psd
  • # Output: Unlocked art/textures/hero.psd
  • Server-Side Push Protection

If Developer Bob attempts to push changes to art/textures/hero.psd while Alice holds the active lock, the Azure Repos or GitHub server rejects the push at the pre-receive hook level , preventing corrupted or conflicting binary versions from entering the branch.

In administrative emergencies (e.g., Alice goes on vacation while holding a lock), an authorized repository administrator can force unlock the asset: # Administrative force-unlock using the lock ID

  • git lfs unlock --id=104 --force
  • Git LFS CLI Quick Reference
  • Command Purpose Operational Context
  • git lfs install Installs global LFS filter drivers and hooks Run once per workstation/agent
  • git lfs track "<pattern>" Tracks file patterns via .gitattributes Run before adding binary files
  • git lfs track "<pattern>" --lockable Configures file pattern for exclusive locking Design/gaming/model assets
  • git lfs ls-files Lists all files managed by Git LFS in the commit Verification & troubleshooting
  • git lfs status Shows staged LFS objects vs Git blobs Pre-commit validation
  • git lfs migrate info --everything Analyzes historical repository bloat by file type Pre-migration planning

git lfs migrate import --everything Rewrites Git history to convert past blobs to pointers Post-bloat remediation

  • git lfs lock <path> Acquires exclusive server lock on a file Prevents binary merge conflicts
  • git lfs unlock <path> Releases active lock Post-merge cleanup
  • git lfs locks Queries server for all active repository locks Team coordination
  • git lfs prune Deletes old local cached LFS objects from .git/lfs Local disk space cleanup
  • git lfs pull Explicitly downloads LFS payloads for current checkout Fast CI build optimization
  • Practical AZ-400 Exam Scenarios & Traps
  • Scenario 1: The CI/CD Clone Timeout

Scenario: A gaming company hosts a Unity repository in Azure Repos. The repository has grown to 35 GB. Azure Pipelines CI builds consistently fail with timeouts during the git clone checkout task. Developers have added .mp4 and .psd files to .gitattributes using git lfs track , but clone times did not improve.

Root Cause: Tracking files with git lfs track only intercepts new commits. The historical commits still contain 34 GB of binary blobs.

AZ-400 Solution: Execute git lfs migrate import --include="*.mp4,*.psd" --everything on an administrative workstation. Force-push the rewritten branches and tags with git push origin --force --all && git push origin --force --tags . Configure the Azure Pipelines YAML checkout step with lfs: false if build agents only require source code, or lfs: true if binaries are needed for compilation.

Scenario 2: Unintentional Binary Commits by Collaborators

Scenario: A team lead initializes Git LFS on their local laptop, tracks *.onnx files, and pushes a new machine learning model. A junior engineer pulls the repository, adds a new model v2.onnx , and pushes it. The remote repository size expands by 1.2 GB, and the new model is not stored in LFS.

Root Cause: The team lead ran git lfs track "*.onnx" but did not commit and push the updated .gitattributes file to the remote repository. Without .gitattributes , the junior engineer's Git client treated v2.onnx as a standard Git blob.

AZ-400 Solution: Always commit .gitattributes into version control in the same commit where LFS tracking is configured. Implement server-side push validation or branch policies to reject commits containing binary blobs larger than a specified threshold (e.g., 50 MB).