Configure and manage repositories for Azure DevOps and GitHub
Learning objectives
- Assign effective repository permissions for a named action and actor.
- Publish identifiable tags and retain work-to-quality traceability.
- Check staged content through hooks while retaining required server-side verification.
- Plan an Azure DevOps-to-GitHub migration and choose Git recovery commands by the affected layer.
Authorize the actual operation
Reading code, managing issues, pushing commits, approving a required review and changing policy are different capabilities. Name the resource and action first. In Azure DevOps, repository permissions inherit from the project-level Git repositories entry; branches inherit a subset. Not set is neither an Allow nor a Deny, so a group or inherited Allow can still apply. An applicable Deny generally overrides Allow. Inspect group membership before using Deny as a quick repair. Under the documented modern behavior, creating a branch does not automatically grant Edit policies.
GitHub organization repository roles include Read, Triage, Moderate, Write, Maintain and Admin. Moderate supports expanded issue management, including editing others' issue text and creating/editing issue labels, but does not permit pushing code, merging PRs or approving required reviews. Write and higher ordinary roles support those code activities; Admin manages access and rules in the standard matrix. Check actual capability rows and organization/custom restrictions, especially packages and rulesets, rather than assuming every capability increases monotonically with role order.
In an illustrative least-privilege decision, a support coordinator needs issue classification and editing but no code changes. Evaluate Moderate rather than granting Write merely for issue editing. A developer who must push needs Write or an appropriate custom role; Moderate does not satisfy that need.
Record the actor, repository and required actions. Inspect base permissions, teams, direct grants and branch rules, apply the narrow assignment, then reread it and verify intended permitted and excluded actions with the intended account. Removing a direct grant may leave team access intact. Deploy keys are separate credentials: possession of a still-authorized private key can outlast organization membership, so review and revoke that access separately.
Make release labels precise
A lightweight tag points directly to an object. An annotated tag has a tag object with metadata and a message; it can also be cryptographically signed. A signature supports authenticity under the chosen signing setup, not test quality. Creating a tag neither publishes it nor deploys its target.
For a verified release commit, the following documentary commands create, inspect and publish one annotated tag:
git tag -a v1.2.0 <verified-commit> -m "Release 1.2.0"
git show v1.2.0
git push origin refs/tags/v1.2.0
Replace the commit only after inspection and confirm the resulting remote ref. If policy requires signing, use and verify the approved signing backend. git push --tags publishes all tag refs. --follow-tags adds missing annotated tags reachable from pushed commits; it does not imply every lightweight tag will accompany an ordinary push.
Local deletion with git tag -d <tag> and remote-ref deletion are separate. Azure Repos remote tag deletion needs Force push permission at the documented repository or All tags scope, with inheritance and creator-specific permissions considered. Other clones retain their copies. Prefer a new unambiguous release label over silently pointing a published tag at different bytes; unavoidable corrections require consumer coordination and verification.
Connect records without overstating quality
Retain the work item or issue, PR, tested SHA, test/quality results and produced artifact together. A link establishes association. Coverage shows executed code, not assertion strength. A green screenshot or mutable title cannot replace the actual run and revision.
Azure Repos can require linked work items. An Optional setting warns without enforcing the same completion block. With native Azure Boards–GitHub integration configured, AB#<ID> in a commit message or PR/issue description can link the item; PR titles and comments are different entry points. Bare references do not close work. The documented keyword transition requires a default-branch PR merge; Fixes targets Resolved or its Completed fallback, not a universally named Closed state. Repeat the keyword for each intended item transition and inspect the actual results.
GitHub issue closing keywords have their own behavior. A PR description targeting the default branch can drive closure; a release-branch PR does not gain the same transition. A closing keyword in a commit message can close an issue when the commit reaches the default branch without listing its containing PR as a linked PR. Manual PR-sidebar linking is within the repository; the issue sidebar can select another repository under its documented conditions.
In a teaching case, Fixes #42 on a main-targeted PR has the intended default-branch closure path, while the same description on a release-targeted PR must not be reported as completed closure. Inspect the issue state, linked PR and required test run separately. If coverage was published while tests were skipped, report missing verification rather than accepted quality.
Check the index, then enforce the pushed revision
Git hooks execute at defined lifecycle points using the hooks directory or configured core.hooksPath. Installation needs the expected runtime and executable permissions. Ordinary working-tree hooks run at its root, while push-triggered hooks use the Git directory. A hook acting on another repository must avoid passing along the first repository's Git environment.
A nonzero pre-commit exit stops commit creation, but --no-verify can bypass it. A receiving-side pre-receive hook runs once for a receive operation, reading old-object/new-object/ref-name records; nonzero rejects that submitted set of ref updates. Custom server-hook availability depends on the host. Installing a local hook does not install enforcement on GitHub.com.
The index contains the proposed commit. Plain git diff compares working files to that index; git diff --cached compares staged content to HEAD, or shows all staged changes when there is no HEAD. To check staged conflict markers and configured whitespace errors, an executable pre-commit hook can run git diff --cached --check and propagate the exit status. This is hygiene verification, not behavioral testing. --check is incompatible with --exit-code, whose purpose differs.
| Illustrative state | Correct interpretation |
|---|---|
| Staged bytes contain trailing whitespace; the working copy is fixed but not restaged | A working-copy check can pass while the proposed commit still fails staged hygiene. |
| Staged bytes are clean; an unstaged edit has the error | A staged check should evaluate the clean proposed commit. |
| A semantic checker compiles with unstaged dependencies | Its result mixes inputs and cannot establish a clean staged-snapshot verification. |
For semantic checks, supply staged blobs or an isolated staged snapshot. Keep final required CI on the pushed commit because local hooks can be absent or bypassed.
Migrate the required data, not just Git objects
Choose between a Git-only transfer and a metadata-aware Enterprise Importer migration. The adopted Enterprise Importer route supports Azure DevOps Cloud to GitHub Enterprise Cloud; Azure DevOps Server is not directly supported by that route. It can migrate Git history and selected PR records and repository branch policies, while user-scoped and cross-repository policies are excluded. Keeping Azure Pipelines and Boards connected is separate from converting pipeline definitions to Actions.
Inventory refs, history, large files/LFS, PR metadata, policy dependencies, identities and integrations. Define destination organization, visibility and identity model. The actor needs organization-owner or granted migrator authority. The adopted ADO2GH route requires a classic GitHub PAT: owner destination/log access uses repo, workflow, admin:org; a migrator uses repo, workflow, read:org. The Azure DevOps PAT needs work item(read), code(read), identity(read). A broader optional inventory-report recommendation is not a universal minimum.
Keep GH_PAT and ADO_PAT in approved secret handling. A policy that forbids classic PATs is a compatibility blocker for this route, not permission to evade policy. Any temporary identity/IP exception or Repository migrations ruleset bypass needs its administrator's authorization and later restoration; it does not exempt future contributions.
Install the CLI extension with gh extension install github/gh-ado2gh, or upgrade an existing installation with gh extension upgrade github/gh-ado2gh. Then generate the reviewed transfer script:
gh ado2gh generate-script --ado-org SOURCE --github-org DESTINATION --output FILENAME
Use verified organization names and a deliberate output path, selecting a trial destination first. Inspect the generated repository mapping and optional actions, then execute the reviewed script in its required shell. Generating a script transfers nothing. A queue-only success means queued; use the documented wait-for-migration completion check and migration logs. Do not invent migrate-repo parameters from unexpanded templates.
Accept the trial through history, representative PR associations, access and integration checks. For final transfer, freeze writes or account manually for changes during and after migration; do not assume delta synchronization. Transfer and verify LFS object bytes separately from migrated pointers. Repositories initially arrive private with limited access. Reclaim eligible mannequin identities for non-commit activity separately from granting membership. Reconnect Boards/Pipelines and restore temporary exceptions. Keep the source until agreed acceptance and rollback conditions are met.
The adopted dated constraints include 2 GiB per commit/push, 255 bytes per ref name, a 400 MiB migration per-file allowance versus 100 MiB for ordinary additions, and a preview 40 GiB source-repository allowance. Recheck such version-sensitive limits before real execution. Search indexing can lag, so temporary search absence is not itself lost history.
An illustrative successful trial with an unavailable LFS asset needs pointer/object diagnosis before repeating the entire migration. Preserved PR activity attributed to a mannequin needs identity reclamation and access review, not blind Git authorship rewriting. No migration or permission change was executed here.
Recover at the correct Git layer
Inspect status, diffs and current revision, preserving work that cannot be reconstructed. Then choose the operation by its intended result:
| Intended result | Command family | Result or limit |
|---|---|---|
| Restore selected working files | git restore, optionally --source |
Defaults to the index; a tracked path missing from the source can be removed. |
| Unstage while retaining working edits | git restore --staged |
Defaults to HEAD; working edits remain. |
| Move a local branch without changing index/worktree | git reset --soft |
Moves history position; unsuitable as an ordinary shared-change undo. |
| Reset index and retain working files | git reset --mixed |
Default reset mode makes staged work unstaged. |
| Match index/worktree to a target | git reset --hard |
Overwrites tracked changes and can overwrite obstructing untracked paths. |
| Visibly undo published work | git revert |
Creates an inverse commit; original history remains and conflicts may need resolution. |
| Stop tracking while keeping a local file | git rm --cached |
Old commits still contain it. |
| Remove untracked files | git clean after a dry-run |
-x includes ignored files; Git may never have stored those bytes. |
For a lost local tip, inspect git reflog, inspect the intended object, then preserve a recovery reference or restore needed content. Reflogs are local, expire differently for reachable/unreachable entries and are not remote backups. Never-stored bytes cannot be assumed recoverable.
For a leaked credential, revoke or rotate it first. File deletion, branch deletion or history rewriting does not invalidate the credential or erase other people's copies. If cleanup is still needed, coordinate affected refs, clones, changed hashes, signature/PR effects and recontamination risks, then restore intended protection after authorized exceptions. Credential containment and repository-content cleanup are distinct outcomes.
Summary
Manage repositories through explicit actors, actions and verified revisions. Tags, relationships and reports retain identity but do not themselves prove quality. Validate the actual staged or pushed bytes, migrate every required data class with separate acceptance, and select recovery operations by the affected Git layer while preserving recoverable work.
