Git won't tracked directory changes so you need remove them yourself after checkout.
Unity would generate .meta
file for every file and directory.
So these hooks use to remove empty directory and its .meta
file for consistency.
- Git for Windows
- Git on macOS
Just copy install-hooks.sh
and hooks
directory to your git repository, then run install-hooks.sh
.
-
file mode
hooks/post-checkout
andhooks/post-merge
don't set executable attribute but set when runinstall-hooks.sh
. It's because ofGit for Windows
.Git for Windows
doesn't setcore.filemode
totrue
. So every file is always644
. -
depth first
When find empty directories, we need find to perform depth-first traversal. And we need delete every empty directory when encountered. So that we could remove nested empty directories.
-
useless files
There are too many useless files exist in working dir, include
.DS_Store
,Thumbs.db
,Desktop.ini
,desktop.ini
. They are generated occasionally by Operating System. These files are usually ignored in.gitignore
file. Then Git treat containing directory didn't exist but Unity don't think so. Unity would generate corresponding.meta
for directory. We need delete these useless ignored files.
You could run hooks/testcase.sh
to build test directory structure.
And then you could run hooks/post-checkout.sh
or hooks/post-merge
to remove empty directories.