modify to fix the issue about redirecting file to itself by tee, and add function commit-each to add missing files with correct comment.