Search code examples
gitgithubopen-sourcegit-filter-branch

Github public repository messed up after history rewritten


We have an issue with our GitHub public repository lyrgard/ffbeEquip for which I am a big contributer.

Recently, the main maintainer and developer Lyrgard realized that his work email address was used in some commit information.

Hence, he followed this helpful Github script to replace all work email by his personnal one. As such, the git history was entirely rewritten. We know of course this isn't something one should do lightly. But he couldn't risk having his work address being associated to his hobby project.

However, the issue is that now we have multiple past commits. Even my commits are shown twice!

The Github script doesn't says anything about it. We tried to search the web for answers, but couldn't find anything useful. We are not expert at git, as I'm sure you have understood by now.

What we actually tried:

We would really like to understand what happened, what is the current situation, and how we can resolve it.

Thanks a lot for your help.

[First edit to add details]

Here is the git log output on master:

commit b2d98cb6674b0a9d2c457cdcf5bf7dc1271d87c5 (HEAD -> master, origin/master)
Author: Lyrgard <[email protected]>
Date:   Thu Aug 30 06:55:43 2018 +0200

    added Golden Apple to recently released items

commit 850244a19880ddcbc0637a17ab01241d6ef0133a
Merge: 362d9a14 ef8c6e12
Author: Lyrgard <[email protected]>
Date:   Thu Aug 30 06:53:18 2018 +0200

    Merge branch 'master' of https://github.com/lyrgard/ffbeEquip

commit 362d9a1409470bd498e5787daa7817400aedd5f1
Merge: 99618a7e 1bca87ad
Author: Lyrgard <[email protected]>
Date:   Wed Aug 29 23:04:46 2018 +0200

    Merge branch 'Indigo744-encyclopedia_killers'

commit ef8c6e125e6d76d04a0fe28e74fce5439bc4f9f2
Merge: 09722cee 8c1b8394
Author: Lyrgard <[email protected]>
Date:   Wed Aug 29 23:04:46 2018 +0200

    Merge branch 'Indigo744-encyclopedia_killers'

commit 1bca87ad243079e0df0599a8e8e414b75b580f68
Merge: 99618a7e 4ce21f1e
Author: Lyrgard <[email protected]>
Date:   Wed Aug 29 23:02:28 2018 +0200

    Merge branch 'encyclopedia_killers' of https://github.com/Indigo744/ffbeEquip into Indigo744-encyclopedia_killers

commit 8c1b83944ade8dbc1eaf1576df00c8e4c46a051b
Merge: 09722cee 5fc10187
Author: Lyrgard <[email protected]>
Date:   Wed Aug 29 23:02:28 2018 +0200

    Merge branch 'encyclopedia_killers' of https://github.com/Indigo744/ffbeEquip into Indigo744-encyclopedia_killers

As you can see, there are two Merge branch 'Indigo744-encyclopedia_killers' and two Merge branch 'encyclopedia_killers' of...

Of course, the commit sha are not equals (otherwise, there would be a huge issue I think) but I can't understand why is there multiple commits?

[Second edit to add more details on what happened]

After discussins with @matthiasbe in the comments, and carefully reviewing the git branch (and discussing with Lyrgard), here what actually happened:

  1. He cloned the repo into a clean temp one
  2. He use the github script filter-branch on this repo to rewrite history
  3. He pushes the whole new history to GitHub.
  4. Delete temp repo. Right now, everything is fine
  5. Went to bed. Next morning, go to his usual repo, pull the changes from Github
  6. Work a bit on it, commit and pushes to Github. this is actually where it is no longer fine

Now the GH has two history (old and new) because, in the second (usual) repo, he should have rebase or delete and clone a new one.

Now that we know what happened, we need to be able to revert this merge from the history

I am looking at rebase -i command but I can't find any merging commit. More help woud be appreciated.


Solution

  • Alright, everything went back to normal.

    What actually saved us is that Lyrgard still had the temporary repository he used to for the filter-branch. It was a "clean" repo, meaning with only the new history, but dated from yesterday (i.e. missing today's commits).

    What we did:

    1. Saved each new commits of the day (they were 3 commits) in separate patch files.
    2. Clone the temp "clean" repo into another one
    3. Apply the patch and commit each time (with same message)
    4. Force push this repo to Github. GitHub now is clean.
    5. Remove all other local repositories
    6. Clone from Github

    At last... Thanks matthiasbe for the help.