Git filter-branch gave me two sets of commits

git

Solution

Given the information from the question, the existing answers, and their comments, it appears that the original poster made a few mistakes after doing the `git filter-branch`, and didn't make a backup clone of the repo.

So here are instructions for returning the repo back to its previous state before the filter-branch, if that is something that the original poster wants to do.

Original references

`git filter-branch` will automatically save references to your old commits, in case you need to recover them for any reason. You'll find them under your repo's `.git/refs/original/refs/` directory:

ls -l .git/refs/original/refs/heads/
total 1
-rw-r--r--    1 Keoki    Administ       41 May 23 01:13 master

ls -l .git/refs/original/refs/tags/
total 1
-rw-r--r--    1 Keoki    Administ       41 May 23 01:13 v1.0

Each of the above references contains the commit sha ID of your old commits:

cat .git/refs/original/refs/heads/master
276fc24dc4b12edf75aea40f4fd50e25a5840005

cat .git/refs/original/refs/tags/v1.0
475593a612141506f59a141e38b8c6a3a2917f85

Use hard resets to recover

To get back your original `master` branch (from before you did the filter-branch), just do a hard reset using the references above, or use the commit sha ID contained in them:

git checkout master

# Use reference
git reset --hard refs/original/refs/heads/master

# Or use sha ID
git reset --hard 276fc24dc4b12edf75aea40f4fd50e25a5840005

Problem

I needed to remove a file from my commit history. I followed Github's instructions for removing sensitive data: ``` $ git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch <myfile>' \ --prune-empty --tag-name-filter cat -- --all ``` ...but I must have done something wrong, because now I have a bunch of duplicate commits. One set of commits still has my file; the other doesn't. Other than that, they're identical. How can I delete all of the commits that still contain my file?

Original source