BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeDesigning and Implementing Microsoft DevOps Solutions (AZ-400)Recovering data with Git
Lesson239 words

Recovering data with Git

Recover specific data by using Git commands

Most "lost" work in Git is not lost. Commits become unreachable rather than deleted, and remain until garbage collection.

SituationCommand
Lost a commit after a reset or bad rebasegit reflog to find it, then git checkout or git reset
Deleted a branchgit reflog for its tip, then re-create with git branch
Want one commit from another branchgit cherry-pick
Undo a commit that is already pushedgit revert
Recover a deleted file from an earlier commitgit restore --source=<commit> <path>

Reflog is the safety net

git reflog records where HEAD has been, including states no branch references any more. It is local and expires, so it saves you on your own machine and not on someone else's — and it is the first thing to reach for after a mistaken reset --hard.

Revert versus reset on shared history

EffectSafe on a shared branch?
git revertCreates a new commit undoing the changeYes
git resetMoves the branch pointer, rewriting historyNo

On anything others have pulled, use revert. Reset rewrites history under everyone's clones, which is the same reason force push is restricted on protected branches.

Primary sources

  • https://learn.microsoft.com/en-us/azure/devops/repos/git/set-git-repository-permissions
  • https://learn.microsoft.com/en-us/azure/devops/repos/git/git-tags
All Designing and Implementing Microsoft DevOps Solutions (AZ-400) Study Resources

Related Notes

  • Agent and runner infrastructure421 words
  • Agent and runner infrastructure — quick notes150 words
  • Alerting on pipeline events255 words
  • Alerting on pipeline events — quick notes94 words
  • Analyzing usage and application performance241 words
  • Analyzing usage and application performance — quick notes73 words
  • Appropriate access levels217 words
  • Appropriate access levels — quick notes85 words
  • Automating container scanning277 words
  • Automating container scanning — quick notes96 words
  • Automating documentation from Git history191 words
  • Automating documentation from Git history — quick notes55 words

Ready to study Designing and Implementing Microsoft DevOps Solutions (AZ-400)?

Practice tests, flashcards, and all study notes — free, no sign-up.

Start Studying

Ready to study Designing and Implementing Microsoft DevOps Solutions (AZ-400)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free
Designing and Implementing Microsoft DevOps Solutions (AZ-400) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.