Created
July 4, 2024 06:13
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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