1

This is a follow-up of this question.

Brief background: The size of the remote repository is far larger than the local version which was caused by pushing a lot of .pngs that were later on deleted by rm filename; this happened on a machine I don't have access to.

My attempts to reduce the size failed, but I was made aware of another thread. I then tried to get rid of all commits that are about images i.e. .png files. I used the following command:

git filter-branch --tree-filter 'rm -f *.png' HEAD

However, I then get the message:

Rewrite 9625aa4ef9368d45b69c605172595322d3da1ea4 (507/507)

WARNING: Ref 'refs/heads/master' is unchanged

and the size of the remote repository is still the same.

How would I use it correctly? There is only one branch, the master branch, in the repository.

Community
  • 1
  • 1
Cleb
  • 25,102
  • 20
  • 116
  • 151
  • Did the wrong commit happen on the `master` branch? If not, then run `git filter-branch` on the correct branch. – Leon Nov 10 '16 at 13:43
  • Also, are all the `*.png` files in the top level directory? The `--tree-filter` is run from the top level of a temporary directory containing a complete `git checkout` of each commit, one commit at a time. This is very slow, so usually it's better to use the `--index-filter` for simple cases like this: the index filter avoids the whole extract/modify/rebuild-index sequence. (However, a tree filter lets you use the full power of the OS on the resulting tree.) – torek Nov 10 '16 at 13:50
  • @Leon: Yes, the commits happened on the master branch. – Cleb Nov 10 '16 at 14:00
  • @torek: the `--tree-filter` part runs through relatively fast, time is not an issue here. Problem is that it does not find any commits i.e. does not change anything which I do not fully understand as there are several pngs in the repository. – Cleb Nov 10 '16 at 14:03
  • To expand a bit on the previous comment: let's say `foo.png` is in commit `master~5` and removed in `master~4`. But, it's actually named `dir1/dir2/foo.png`. Your tree filter will not remove it because `*.png` does not look inside `dir1`, much less `dir2`. You would need a tree filter with `rm -f dir1/dir2/*.png` or `find . -name '*.png' -print0 | xargs -0 rm`, for instance. – torek Nov 10 '16 at 14:19
  • @torek: Ok, I did not know that. I will give that a try as well; as it is only about one directory, it should be fast to test it. – Cleb Nov 10 '16 at 14:24

0 Answers0