Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a commit based on its message content or filename with git filter-repo --commit-callback #534

Open
tomdev92 opened this issue Jan 7, 2024 · 0 comments

Comments

@tomdev92
Copy link

tomdev92 commented Jan 7, 2024

I am attempting to remove a commit from my repository history based on its message or filename by using commit.skip() . However, it seems that once the conditional statement evaluates to true, all subsequent commits in the history are skipped, irrespective of the condition.

The code I have been using to skip a commit based on its filename is the following:

git filter-repo --commit-callback 
 for change in commit.file_changes:
  if b"index" in change.filename:
   commit.skip()

whereas for skip a commit based on its message content is the following:

git filter-repo --commit-callback 
 if b"index" in commit.message:
  commit.skip()

The logic of the conditionals is correct, as when I use

git filter-repo --commit-callback 
 if b"index" in commit.message:
  commit.message = b"new commit message"

it works perfectly fine, affecting only the commits which respect the conditional statement.

I have not found any indication on how the skip() works in the git filter-repo documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant