ファイル属性の変更を git 上で管理する
Windows で作成したファイルを git push し、Linux や FreeBSD で git pull したファイルの属性は、0644 で記録されている。
これらのファイルに実行権限 (ファイル属性の変更) を付与して、git commit して git push した後に、Windows で git pull すると、付与した実行権限が反映されていない。
その場合は、Windows 上ならば、Git Bash で、Linux や FreeBSD などではコマンドライン上で下記の作業を実施する。
% ls -l -rw-r--r-- 1 littlebuddha wheel 329 Jul 30 17:49 sample.pl % git ls-tree HEAD sample.pl 100644 blob e269d073bc1b03ad0a1281a7f005010d416670ec sample.pl % chmod u+x sample.pl % ls -l -rwxr--r-- 1 littlebuddha wheel 329 Jul 30 17:49 sample.pl % git ls-tree HEAD sample.pl 100644 blob e269d073bc1b03ad0a1281a7f005010d416670ec sample.pl % git update-index --chmod=+x sample.pl % git ls-tree HEAD sample.pl 100644 blob e269d073bc1b03ad0a1281a7f005010d416670ec sample.pl % git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: sample.pl # % git commit -m "add executable attribute." [master 61e6875] add executable attribute. 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 sample/sample.pl % git ls-tree HEAD sample.pl 100755 blob e269d073bc1b03ad0a1281a7f005010d416670ec sample.pl
で完了。ファイル属性の変更を記録しておくことで、Windows で git pull し、ファイルの変更を加えた後に commit と push をしても、上記で記録した実行権限 (ファイル属性の変更) は反映されたままになっている。