Domain 2 β€” Module 3 of 3 100%
7 of 27 overall
Domain 2: Design and implement a source control strategy Free ⏱ ~7 min read

Migration and Recovery: Preserve History Before Changing It

Plan an Azure DevOps-to-GitHub migration, choose revert rather than destructive reset on shared history, and respond correctly to committed secrets.

Moving house is more than moving the furniture

Copying a repository’s Git objects is like moving the furniture. Permissions, build connections, work-item links, large files, and release automation are the utilities and address changes. A migration is incomplete if code arrives but nobody can build or trace it.

Choose the migration mechanism after inventorying what must survive. A Git mirror moves Git history and refs, not every platform object. GitHub Enterprise Importer supports a documented Azure DevOps migration path with its own prerequisites, supported data, and exclusions. Do not promise that every Boards item, pipeline setting, extension, policy, or secret migrates with the repository.

Plan before importing

InventoryQuestion to answer
RepositoryWhich branches, tags, sizes, and LFS objects exist?
CollaborationWhich PRs, identities, discussions, and links must remain usable?
SecurityWho may migrate, administer, contribute, and bypass?
AutomationWhich webhooks, service connections, runners, and pipelines need recreation?
ConsumersWhich clones, submodules, package references, and integrations use the old URL?
CutoverWhen is the source frozen and what is the rollback criterion?

Use a test migration first. Keep tokens out of command history and logs; follow the current tool’s authentication guidance rather than embedding secrets into a remote URL.

For Azure DevOps-to-GitHub Enterprise Importer, verify the current licensing, organization prerequisites, supported destination, and source access. Git LFS objects are not included in the documented importer migration; plan their separate transfer and verification. A small successful Git checkout does not prove large assets arrived.

Verify the destination as a working system

After the test import, compare branch heads and tags, inspect representative history and PR links, fetch LFS content where used, and run the actual build from a clean clone. Recreate required branch policies/rulesets deliberately; do not assume source controls become equivalent destination controls automatically.

Test one integration end to end: open a draft PR, run checks, inspect work tracking, and confirm the intended reviewer and access restrictions. Verify that old service credentials are not accidentally retained or exposed. Keep the old source read-only during a controlled observation period if the migration plan calls for it.

Do not delete the source merely because the importer reports success. A tool-completed operation is one part of acceptance, not the entire cutover decision.

Choose recovery by what must be preserved

SituationUsually appropriate starting pointMain caution
Bad commit already sharedgit revertCreates a new inverse commit; conflicts and tests still matter
One file needs its older contentRestore that path from a known commit, then review and commitCan overwrite local work on that path
Local branch pointer moved unexpectedlyInspect git reflog and create a recovery branchReflogs are local and not indefinite backups
Secret committedRevoke/rotate first, then coordinate history cleanupDeleting the visible file does not revoke the credential

Use these read-oriented commands to inspect a disposable repository:

git status --short
git log --oneline -5
git show HEAD
git reflog -5

If a non-merge shared commit introduced a bug, a revert records a new change rather than erasing other contributors’ history:

git revert <BAD-COMMIT>

Replace the placeholder only after inspecting the exact commit and ensuring the working tree is ready. Merge commits require an explicitly chosen mainline and additional reasoning; do not treat them as interchangeable with ordinary commits.

reset --hard and force-pushing can destroy uncommitted changes or rewrite history others depend on. They are not routine first responses to a shared mistake. An assistant should explain the effect before proposing them.

A leaked secret is an incident, not just a Git task

Revocation or rotation removes the credential’s usefulness. History rewriting removes selected content from reachable history under a coordinated procedure. Both may be needed, but one does not replace the other.

Check forks, clones, logs, artifacts, and cached references within your incident process. Avoid placing the real secret into a search command that will itself be logged. Use supported secret-scanning tools and identifiers. Coordinate rewritten history with collaborators and the hosting provider’s documented sensitive-data removal process.

Knowledge Check

A usable production token was committed and then deleted in a later commit. What is the first priority?

Try it: rehearse a reversible recovery

Prerequisites: Git and a new local disposable repository. Use harmless text only; never create a real secret for this exercise.

  1. Commit a text file, then commit an intentionally incorrect sentence.
  2. Inspect both commits and revert the second one.
  3. Confirm the corrected content and the three-step history: original, mistake, inverse.
  4. Write a migration acceptance checklist covering Git refs, large assets, access, CI, and one integration.

Expected observation: the revert preserves the original history and adds an auditable correction. Your checklist distinguishes Git transfer from platform cutover.

Cleanup: remove only your disposable exercise repository using your normal safe cleanup process. No hosted migration or production credential mutation is required by this exercise.

Question

Why is reflog not a repository backup?

Click or press Enter to reveal answer

Decision check: the import succeeded but a build fails

Compare the build’s dependencies, secrets, runner access, LFS assets, and old URL references before blaming the imported source. Migration acceptance requires a usable delivery path.

Read the source