This project provides a simple GitHub Repository Creator script that automates the process of creating GitHub repositories directly from the terminal. The script interacts with GitHub’s API to create new repositories, either private or public, and optionally adds a README file to the repository. The project aims to simplify repository management by streamlining the creation process with minimal inputs.
- Create GitHub repositories directly from the terminal.
- Option to make the repository private or public.
- Option to add a README file during repository creation.
- Secure integration with GitHub API using environment variables and Personal Access Tokens (PATs).
- Lightweight and efficient – no need to manually navigate the GitHub interface.
Before running the script, make sure you have:
- GitHub account with API access.
- A Personal Access Token (PAT) with the required permissions to create repositories.
To securely authenticate and interact with the GitHub API, you need to create a Personal Access Token (PAT).
- Go to the top right corner of GitHub and click your profile picture, then select Settings.
- Scroll down in the left menu and select Developer settings.
- Select Personal access tokens (fine-grained).
- Click Generate new token.
- Give the token a name (e.g., "GitHub Repo Creator").
- Set the expiration date to 1 day (custom).
- Under Repository access, select All repositories.
- Under Repository administration, select Read and write access.
- Click Generate token and copy the token. Keep it secure, as you won’t be able to view it again.
git clone https://github.com/nsahil992/Github-Repo-Creator.git
Create a .env
file in the same directory as the script to store your sensitive information like your GitHub username and PAT.
From your terminal, if the Github-Repo-Creator exits in on your Desktop then:
cd /path-to-the-cloned-repo
- In the script directory, run:
touch .env
- Open the
.env
file:vim .env
- Add your GitHub username and PAT:
GITHUB_USERNAME=your_github_username GITHUB_TOKEN=your_personal_access_token
- Save the file (press
Esc
thenShift + :
, andwq
to exit). - Ensure the
.env
file is kept private:chmod 600 .env
To prevent your .env
file from being pushed to a public repository, add it to .gitignore
.
- Create or open the
.gitignore
file:touch .gitignore vim .gitignore
- Add
.env
to the.gitignore
file:.env
- Save and close the file.
Once the setup is complete, make the script executable and run it:
- Make the script executable:
chmod +x github-repo-creator.sh
- Run the script:
./github-repo-creator.sh
- The script will prompt you for the repository name, privacy setting (private or public), and whether to add a README file. Follow the prompts to complete the process.
🥳🎉! Your GitHub repository is created!
This script simplifies the process of creating repositories on GitHub, saving you time and effort. With a simple setup, you can start creating repositories securely with minimal interaction. Make sure to safeguard your token and keep it within your .env
file.
Security Reminder:
- Always use tokens with limited permissions, only granting access to necessary resources.
- Rotate your tokens regularly to mitigate any potential security risks.
- Do not share your
.env
file publicly or commit it to version control.