1

Git has an advanced command called filter branch for making various complex changes to a repo's git history. I intend to use this to fix some accidental mistakes in my repo, but I'm not experienced with it and I want to make sure I don't accidentally do something wrong.

Once I apply my git filter branch command(s), I will end up with a new repository that has the git history altered. I'd like to compare it to the one before filter branch to make sure that exactly those changes I intended have been made.

By doing a simple recursive diff, I can check that the final state of the repo is as expected. But what about the history? If I diff the .git directory, I suspect it won't be much help. What else can I do to see which commits differ between two repos, across all branches?

Wassinger
  • 347
  • 2
  • 16

2 Answers2

2

First, do a filter operation on a separate clone, in order to easily go back to the original state if needed.

Plus, you will be able to do a git log in each repository, for comparison.

Second, consider using git filter-repo instead of the obsolete git filter-branch.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So are you suggesting I simply `diff` the `git log` output for either repo? – Wassinger Dec 02 '21 at 08:01
  • 2
    @Wassinger Exactly, that seems one easy way to see the changes. Omit the SHA in your git log command, since those will differ anyway. – VonC Dec 02 '21 at 08:03
0

Technically, you will have all your commits (both pre- and post- filter-branch / filter-repo) in the same repository.

You can check your reflog, spot the relevant commits, and use these with git log or git diff.

You can use the per-branch reflog to scan a shorter list of commits :

git reflog target/branch

# you can either use the shas listed in the reflog,
# or the '@{xx}' references mentioned next to them :
git log --graph --oneline target/branch@{3} target/branch
LeGEC
  • 46,477
  • 5
  • 57
  • 104