Forked repo hundreds of commits ahead of original after running Githubs chaning author info script.

So I ran GitHub's script to fix author info in old commits, now GitHub says that my forked repo is hundreds of commits ahead of the original repo. How do I fix this? I already pulled from the upstream repo and merged conflicts, but I'm still hundreds of commits ahead, and they aren't my commits.

When I click "compare", it shows me commits that aren't mine. I'm pretty confused as to what happened. Any help would be appreciated.

Posted Sep 16, 2017, 6:48 PM UTC

15
[deleted]•

[deleted]

1
[deleted]•

[deleted]

1
kr583OP•

Even if I only rewrote the author info for a few recent commits? Why does that rewrite every commit?

Is there any way to undo it? Thanks

1
michael0x2a•

When you change a commit, you're also implicitly changing every single commit that builds on it.

More precisely, each commit is uniquely identified by a sha1 hash which is computed by basically combining:

  • The commit and author metadata
  • The parent commit(s) sha1 hash(es)
  • Your file's combined sha1 hash

So this means that when you change a commit, you force any commits that depend on it to update their own hash, then their children need to do the same... This propagates all the way down the chain of commits.

To remove your modified commits from the repo, you can try:

  1. Fetching back all the commits from the original repo (we'll call this upstream), moving the "master" label so it's back in sync with upstream/origin, then force-pushing your changes to origin/master, discarding all of your commits in the process. You may need to repeat this for any other branches you may have. Keep in mind these are all relatively destructive changes, so you should be careful when stepping through these operations.
  2. Giving up, deleting your forked repo, then re-forking it. This is a bit crude, and you'd lose any original work you did, but it's more straightforward.
1
kr583OP•

I have a few open Pull Requests from this fork, how would all of this affect those PRs? Could I potentially just leave it all alone?

1
michael0x2a•

In that case, you probably don't want to delete your forked repo.

If the pull requests are based on the original unchanged commits, then you're probably ok. If they're based on the modified commits, it's hard to say for certain (I'd need to look at the actual state of your git repo), but you're probably going to want to rebase them so they're back in sync.

If it helps, if Github's web UI says that your pull requests are ok to merge, then you're probably ok.

1