Trying to prune a repository

I used to run

git filter-branch --parent-filter "'test $GIT_COMMIT == ${mycommit} && echo \"\" || cat '" HEAD

to prune my repositories (drop commits older than ${mycommit}).

However this seems no longer possible I get one of the two following errors:

Cannot rewrite branches: You have unstaged changes.

But before executing the command all changes have been committed and pushed.

The command is run off a temp file that shows up as untracked.

The other error I am getting is a parent filter failed:

Rewrite 3f6bf4c315c857f1960eab5736101df770a84200 (1/) (0 seconds passed, remaining 0 predicted) parent filter failed: test $GIT_COMMIT == 819d3fbad8633df66708248449d9083325edc4a7 && echo "" || cat

Can anybody help me there?

OS = windows 10

bash -version
GNU bash, version 4.4.12(1)-release (x86_64-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>

$ git --version
git --version
git version

Hi there! I’m not sure exactly why you’re getting that error if you’ve already added and committed all changes ahead of time. We could probably figure it out with some back and forth, but before going that direction I wanted to suggest the solution that we typically point people towards when they’re interested in truncating their Git history:

git checkout --orphan temp <SHA> # checkout to the status of the git repo at the given commit; creating a branch named "temp"
git commit -m "new root commit" # create a new commit that is to be the new root commit
git rebase --onto temp <SHA> master # now rebase the part of history from <SHA> to master onthe temp branch
git branch -D temp # we don't need the temp branch anymore

Obviously back up the repo before trying any changes like this :slight_smile: That should do the trick, but feel free to follow up if you’re still having trouble!