Skip to content

Instantly share code, notes, and snippets.

@8thgencore
Created July 4, 2024 06:13
Show Gist options
  • Select an option

  • Save 8thgencore/f91eb4a375d3f81c90d9803186ce3255 to your computer and use it in GitHub Desktop.

Select an option

Save 8thgencore/f91eb4a375d3f81c90d9803186ce3255 to your computer and use it in GitHub Desktop.
A Bash script that converts directories to Git repositories by creating a .git directory, moving files and subdirectories into it, and setting up the repository. Run this script in the root directory of your project to create a Git repository in each subdirectory.
#!/bin/bash
# Переменная для хранения пути к директории
root_dir="/path/to/root/directory"
# Проходимся по всем папкам в директории
for dir in "$root_dir"/*; do
# Проверяем, является ли это папкой
if [ -d "$dir" ]; then
# Создаем каталог.git
mkdir "$dir"/.git
# Перемещаем файлы и папки в.git
mv "$dir"/* "$dir"/.git/
# Переходим на директорию
cd $dir
# Конвертируем репозиторий с помощью git config
git config --local --bool core.bare false
# Запускаем git reset --hard
git reset --hard
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment