Enno Shioji
Enno Shioji

Reputation: 26882

How to go about diagnosing/fixing a git repo

Our central git repository got in a weird state after a commit that involved a reseted local repository.

I'm not 100% sure exactly what was done in this commit, but after this commit, changes from other commits can get silently overriden with older versions when stuff is pushed from this reseted local repository ("silently" means that overwrites of other commits don't appear in the change history).

My questions are:
(1) How do I diagnose what happened (preferably without access to the reseted local repo)?
(2) Should I not be able to find out what happened, what is the best course of action to get rid of this state?

For (2) I am thinking about (a) discard the problematic local repo and never use it again, (b) HARD reset the central repo before the problematic commit and replay the commits excluding the problematic commit, manually.

Upvotes: 0

Views: 108

Answers (1)

kan
kan

Reputation: 28981

You could see all changes made by a commit using git show <commit-id>. Not sure what do you mean by "overwrites of other commits don't appear in the change history", there is no such thing as a overwrite in git, there are commits only.

So, you have identified a problematic commit? When just git revert it.

Or a branch was rewritten by force push (some commits are disappeared from history)? That's worse, you should use git fsck −−lost-found until it is garbage collected.

Next time configure the central repo to forbid non-fastforwards by receive.denyNonFastForwards=true or at least enable reflogs by logAllRefUpdates=true.

Upvotes: 1

Related Questions