Home > OS >  How can I diff a repo before and after filter branch?
How can I diff a repo before and after filter branch?

Time:12-02

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?

CodePudding user response:

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.

CodePudding user response:

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
  • Related