feat(git): add comprehensive git folder management commands and update documentation

This commit is contained in:
Janik von Rotz committed 2026-03-04 09:36:40 +01:00
1 parent 793b608732
commit 84f7ebfccb
15 files changed
+342 -10

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
clone-git-folder() {
if [[ -z "$1" ]]; then
echo '$1/path is empty.'
exit
fi
local git_folders=$(ls-git-folder "$1")
for git_folder in $git_folders; do
git_folder="${git_folder#./}"
local git_folder_path=$(git config --file .gitmodules --get submodule."$git_folder".path)
local git_folder_url=$(git config --file .gitmodules --get submodule."$git_folder".url)
local shallow=$(git config --file .gitmodules --get submodule."$git_folder".shallow)
local git_folder_branch=$(git config --file .gitmodules --get submodule."$git_folder".branch)
if [[ "$shallow" = "true" ]]; then
echo "Clone git folder $git_folder (shallow) with $git_folder_branch branch"
git -C "$git_folder" config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git clone --depth 1 --no-single-branch "$git_folder_url" "$git_folder_path"
else
echo "Clone git folder $git_folder with $git_folder_branch branch"
git clone --branch="$git_folder_branch" "$git_folder_url" "$git_folder_path"
fi
done
}