A Bash script to upload multiple folders as individual repositories to GitHub. This script is designed to automate creating Git repositories for each folder in a specified directory, setting up .gitignore rules, and pushing them to GitHub.
- Automatically creates a Git repository for each folder inside a specified base directory.
- Allows you to:
- Use a predefined
.gitignorepreset. - Add custom
.gitignoreexceptions.
- Use a predefined
- Configures user name and email for each repository.
- Pushes each folder as a separate repository to GitHub.
- Removes any existing
.gitfolders to ensure clean initialization. - Supports creating repositories as public or private based on user preference.
- Automatically replaces spaces in folder names with
-to create valid GitHub repository names.
- Git
- GitHub CLI (
gh) - Bash Shell
If you have the "Keep my email address private" option enabled on GitHub, you will need to use the email format provided by GitHub (e.g., 12345678+username@users.noreply.github.com).
- Go to your GitHub Email Settings.
- Under the "Email address privacy" section, check for your
no-replyemail address. It will look like:12345678+username@users.noreply.github.com - Use this email address when prompted by the script.
-
Clone or download this repository.
-
Open your terminal and navigate to the directory containing
BPU.sh. -
Make the script executable:
chmod +x BPU.sh
-
Run the script:
./BPU.sh
Or if you encounter a permission issue, run:
bash BPU.sh
-
Follow the prompts:
- Enter the base directory path containing the folders you want to upload.
- Enter your GitHub username and GitHub email.
- Choose whether to use a
.gitignorefile:- Default Preset: Excludes common files like
*.mp4,*.zip,node_modules/, etc. - Custom Exceptions: Allows you to define your own rules for
.gitignore.
- Default Preset: Excludes common files like
- Select whether the repositories should be public or private.
Here’s an example of how the script works:
-
Suppose your base directory
/projects/contains the following folders:/projects/ my project/ another_project/ final project/ -
The script will:
- Rename folders with spaces to valid repository names:
my project->my-projectfinal project->final-project
- Initialize a Git repository in each folder.
- Configure GitHub username and email.
- Optionally create and apply a
.gitignorefile. - Create a corresponding repository on GitHub (e.g.,
username/my-project). - Push all files (except those excluded by
.gitignore) to GitHub.
- Rename folders with spaces to valid repository names:
The default .gitignore preset excludes the following:
- Common large files:
*.mp4,*.pdf,*.zip,*.rar,*.ai,*.psd,*.indd,*.idml
- Node.js-related files:
node_modules/,.env,.npm/,logs/,dist/,coverage/
- Development files:
.vscode/
- Ensure you have the necessary permissions to create repositories on your GitHub account.
- For private repositories, the script uses GitHub CLI to automate the process. Make sure
ghis configured properly. - The script uses
--forcewithgit pushto overwrite any existing data. Be cautious when re-uploading projects.
Feel free to fork this repository and submit pull requests for improvements or bug fixes.
This script is open-source and available under the MIT License.