Git History Rewrite and Steps to Adjust

Hello Chapel community,

Yesterday, we rewrote a part of the Chapel language's git history,
going back about 12 days. This is a change that may affect your existing
local repositories of Chapel.


Five days ago, a large file was accidentally commited to the Chapel repository.
This file was the result of a homebrew test build. This large file caused
problems checking out Chapel in certain situations (as git is not particularly
good at handling large binary files). To help mitigate this issue, we decided
to rewrite the Git history to remove the large file from it altogether.

We understand that this change has been quite disruptive, and we
do not intend to do something like this again

What did we do?

We rewrote the commits on main after the one with hash
d7901801e024c26d19163e2ff095f77527933396 as of around 3:15pm Pacific Time
on January 30. This was required as Git commits include the hashes of commits
that precede them; thus, it is impossible to remove or modify a commit in Git
history and leave the subsequent commits intact.

How does this affect developers?

If your local checkout of Chapel and your outstanding PRs and branches
are older than commit d7901801e, there should be nothing out of the ordinary
for you to do. However, if you have pulled the repository in the last 12 days,
and made new branches, you will have to do some work to make those
compatible with the current, upstream main branch on chapel-lang/chapel.

The message you will see if you are affected by this change is something like:

Your branch and 'upstream/main' have diverged,
and have 198 and 245 different commits each, respectively.

You only need to perform the following steps if you pulled onto main
in the last 12 days, or if you have branches forked from commits in the last
12 days.

Updating your local main branch

To update your local main branch with the updated history on GitHub, follow
these steps:

  1. Stash or otherwise preserve any changes you might've made to existing files
    • e.g.,
      git stash
  2. Check out main in your repository:
    git checkout main
  3. Fetch the new commits from the upstream remote:
    git fetch [NAME OF REMOTE]
    • If you do not know the name of your upstream remote, find it by running
      git remote --verbose and finding the entry whose url points to
  4. Back up your main branch and then reset it to be the same as the one on GitHub:
    git branch main-backup
    git reset --hard [NAME OF REMOTE]/main
  5. Push your updated main branch to your Chapel fork:
    git push origin main --force-with-lease

Updating your branches

This step assumes you've already updated your main as described in the steps

  1. Check out your feature branch
    git checkout my-branch
  2. Begin an interactive rebase on top of the main branch.
    git rebase main -i
    The above command will open a text editor.
  3. Delete the lines with commit hashes:
    e37bc915bd, 07658d1488, 6bd4bcee5f, c77ffc71da, 87c24400b4.
    These should all be commits with the text "Added homebrew_ci Automation".
  4. Save and quit the text editor.
  5. Push your branch to your remote.
    git push origin my-branch --force-with-lease

FYI, make sure you're using the same remote names for the same purposes as above before running the commands as-is. For example, I started my chapel development by cloning the main repo which is now my origin, and my fork is named something else.

1 Like

I've had a similar issue. @daniel.fedorin, what do you think about editing your original post to use a placeholder that's (hopefully) obviously not meant to be typed in literally, like [NAME OF REMOTE], and maybe indicating that the way to get this name is to do a git remote --verbose and to look for the entry corresponding to

One other clarifying edit that could be made would be to put an 'e.g., git stash' type helper after step 1 (or maybe there's a better best practice than that—I'm not very good at git stash). On updating my nth repository, I stopped reading every word and just typed the commands, so skipped right past this.


ITYM git remote --verbose

1 Like