4

3 questions concerning git push --force :

Is there a way to detect when someone on a team make a git push --force ?

Is it-possible to make a hook that send an email when my local git installation detect that a git push --force ?

Is there a way to see if some commit disappear on my branch after this git push --force ?

Naremy
  • 491
  • 8
  • 22
  • Note: on GitHub, this detection has just gone considerably easier: https://stackoverflow.com/a/53343686/6309 (Nov. 2018) – VonC Nov 16 '18 at 19:01

1 Answers1

2

Is there a way to detect when someone on a team make a git push --force ?

Yes.

You have this hook which you can use:
https://github.com/kyanny/git-hooks-detect-force-update


Is it-possible to make a hook that send an email when my local git installation detect that a git push --force ?

The first answer is hook so you can send email from the hook.


Is there a way to see if some commit disappear on my branch after this git push --force ?

Not directly, you will have to scan the repo for dangling objects.

git fsck --full

But in the hook above you will get the commits which will be remove

CodeWizard
  • 128,036
  • 21
  • 144
  • 167