0

We are using git (with Bitbucket and SourceTree). We lost 6 months of check ins in our master branch and I wander if there is a way to determine what happened. Is there command in git and or Bitbucket/SourceTree that can tell me if the reset was performed and/or all the commands/operations on the (remote) branch.

eddieO
  • 84
  • 1
  • 7
  • 1
    The branch could be force-pushed or deleted and recreated. Check the updates of `master` on Bitbucket. The "lost" commits could be found at a local repository that has been updated since it was cloned some time ago. – ElpieKay Nov 30 '17 at 01:35
  • Pretty sure you can't get an audit of revised history changes, but you can restrict what branches can be deleted or have their history revised. – Derek Nov 30 '17 at 05:08

2 Answers2

2

We lost 6 months of check ins in our master branch and I wander if there is a way to determine what happened.

No, there is no way in pure git to know who did it. Perhaps in some logs or audit on bitbucket but chances are little.

But the more important is more to email developers to explain them that force push should not be made on master ( perhaps you should consider protecting your master branch https://blog.bitbucket.org/2013/09/16/take-control-with-branch-restrictions/) and very carefully on other branch (only allowed in feature branches!?!)

We lost 6 months of check ins in our master branch

I hope this is a pure rhetoric sentence! The history could be easily retrieved from local repositories using the reflog.

Philippe
  • 28,207
  • 6
  • 54
  • 78
  • Yes, we were able to recover all the changes from the local repo. We have a dev/master scheme where developers aren't supposed to check in into master and our build jobs perform merges from dev branches. So, I am trying to figure out if it a human error situation, perhaps the merge job issue or something else. But we don't lock down master so this is something to consider. What is more curious is that didn't just reset back in time but also had 2 changes that are not in current local branches of any developer. – eddieO Dec 01 '17 at 00:03
  • "But we don't lock down master so this is something to consider." - Absolutely. On master it's a good idea to disallow force pushes. Another restriction that works well is only allowing changes to master via pull requests (via Branch Permissions). – JVDL Dec 01 '17 at 04:14