빈 디렉토리가있는 테스트 저장소를 설정하려면 다음 스크립트 (임시 디렉토리에서 실행)를 사용할 수 있습니다.
그러나 체크 아웃 할 때 빈 디렉토리는 무시됩니다. 여기에서도 Git은 디렉토리가 아니라 파일에서만 작동합니다.
Github 및 tig
빈 디렉터리 표시, gitk
.
#!/bin/bash
set -e
echo ---- initialize the repo...
#rm -rf .git
git init
echo ---- create an empty tree object...
empty_tree=$(git mktree < /dev/null)
echo ---- create a parent tree containing the empty subtree...
root_tree_ls=$(echo -e 040000 tree $empty_tree\\tvacuum)
root_tree=$(echo "$root_tree_ls" | git mktree)
echo ---- commit...
commit_msg="This commit contains an empty directory"
commit=$(git commit-tree $root_tree -m "$commit_msg")
echo ---- create a branch...
git branch master $commit
# output the ids:
echo ----------------------------------------------------
echo "empty tree:" $empty_tree
echo "root tree: " $root_tree
echo "commit: " $commit
사실이 트리는 저장소에 빈 트리를 추가합니다. 그러나 repo를 복제해도 작업 트리에 빈 디렉토리가 생성되지는 않습니다. – manu