0

My understanding is; if a developer does a git reset --hard <commit> and git push --force, that commit will be permanently deleted from the Git repo.

  1. Is there a way to recover the commit from the above action?
  2. How can we or shall we stop this type of actions?
castis
  • 8,154
  • 4
  • 41
  • 63
Jirong Hu
  • 2,315
  • 8
  • 40
  • 63

1 Answers1

1
  1. The commit will be deleted during git gc if there are no other references left to that commit. That commit may be referenced by a tag or other branch and in this case it won't be deleted.
    If you recently checked out this commit locally you may find it in git reflog.

  2. See link in comment by @AlexanderGuz.

Paul
  • 13,042
  • 3
  • 41
  • 59