https://github.com/networm/unitygithooks
Remove empty directories after git checkout for Unity
https://github.com/networm/unitygithooks
Last synced: about 1 year ago
JSON representation
Remove empty directories after git checkout for Unity
- Host: GitHub
- URL: https://github.com/networm/unitygithooks
- Owner: networm
- License: mit
- Created: 2016-06-26T07:19:02.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-10-17T14:48:17.000Z (over 7 years ago)
- Last Synced: 2025-04-12T06:13:19.887Z (about 1 year ago)
- Language: Shell
- Homepage:
- Size: 5.86 KB
- Stars: 13
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unity Git hooks
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.
## Environment
- Git for Windows
- Git on macOS
## Usage
Just copy `install-hooks.sh` and `hooks` directory to your git repository, then run `install-hooks.sh`.
## Notes
* file mode
`hooks/post-checkout` and `hooks/post-merge` don't set executable attribute but set when run `install-hooks.sh`.
It's because of `Git for Windows`. `Git for Windows` doesn't set `core.filemode` to `true`.
So every file is always `644`.
* 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.
## Test
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.
## Reference
* [3pjgames/unity-git-hooks: Git hooks for Unity3D project](https://github.com/3pjgames/unity-git-hooks)