How to rewrite history to remove executable bit in git

I imported a rather large repository from another SCM to git. Unfortunately, the migration was (should be) done on Windows, and each file was transferred to git with the execution bit set. To avoid re-migration (this is a long and freezing process), I am trying to find out if I can clear the server server executable bit. My thought is using the git filter-branch branch somehow in combination with git update-index, but I could take hints as to how to proceed.

Making a huge commit at the end, clearing all the executable bits is not a solution - I don't want every file to have a relief in the history.

+4
source share
2 answers

This seems like a trick:

git filter-branch --index-filter 'git ls-files -s | sed s/^100755/10644/ | git update-index --index-info' -- --all 
+5
source

Your solution is not bad, but there is another possibility: git config core.filemode false :

http://git-scm.com/docs/git-config

core.fileMode

If false, differences in the executable bit between the index and the working copy are ignored; useful for broken file systems such as FAT. See git -update-index (1).

The default value is true, with the exception of git -clone (1) or git -init (1) will check and set core.fileMode false if necessary when the repository is created.

This may create more work for anyone who should clone the repo in the future (or it may not be so, I'm not sure), so your solution is probably better, but I thought I would throw it there as it might be more suitable for someone else use the case ...

+1
source

All Articles