tags:

views:

183

answers:

2

I'm such a clever person.

I decided to clean up the "unknown" commits in my repository by running a command from this blog post:

git filter-branch --commit-filter '
        if [ "$GIT_COMMITTER_NAME" = "unknown" ];
        then
                GIT_COMMITTER_NAME="a2h";
                GIT_AUTHOR_NAME="a2h";
                GIT_COMMITTER_EMAIL="*snip*";
                GIT_AUTHOR_EMAIL="*snip*";
                git commit-tree "$@";
        else
                git commit-tree "$@";
        fi' HEAD

At first I thought everything was fine, until I noticed in gitk that every commit prior to running this was duplicated, not simply edited as I originally thought.

As a result by GitHub network graph has also been completely messed up with its indication of what commits happened, and what merges happened and into where.

Is it possible to clean up this mess in any way?

EDIT: OK, gitk is showing both the old commits (the ones with the "unknown" commiters mixed in) and the new commits (the rewritten ones), split up at a certain point around halfway. Think a bunch of commits, then duplicated (and with the edits), and stacked on top of the original ones. What I want to do is if possible, kill off the original ones.

+1  A: 

If you know the last good commit, save your bacon with this:

git reset <last_good_commit>   # Warp back to a good state.
git push -f master             # Push the changes up (you need -f to force it to
                               #  obliterate old commits).

If you want to tread more carefully (for example, if there are good and bad commits mixed in after <last_good_commit>), use git rebase -i to cherry-pick the good ones that should stay behind.

John Feminella
I'm not very familiar with the command line, and I'm not sure what cherry picking or rebasing are... also, I've added a clarification on what I want to do.
a2h
+1  A: 

The answer was the files in .git/refs/original, and how the command I found should not have ended in HEAD but instead with --tag-name-filter cat -- --all.

Cheers to _Vi and wereHamster from the #git channel for the help.

a2h