एक खाली निर्देशिका के साथ एक परीक्षण भंडार स्थापित करने के लिए, आप निम्न स्क्रिप्ट का उपयोग कर सकते हैं (इसे अस्थायी डायरेक्टॉय में चलाएं)।
चेक आउट करते समय, खाली निर्देशिका को अनदेखा किया जाता है। यहां भी, गिट केवल फाइलों के साथ काम करता है, निर्देशिका नहीं, भले ही उत्तरार्द्ध मौजूद हों।
गिथब और 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
यह वास्तव में भंडार में खाली पेड़ जोड़ता है। लेकिन रेपो क्लोनिंग आपके काम करने वाले पेड़ में खाली निर्देशिका नहीं बनाता है। – manu