FastRepo is a Python script that automates the creation of a new GitHub repository and commits the current directory's contents to it, including the setup of a .gitignore
and a LICENSE
file without user intervention.
- Creates a new GitHub repository with the current directory's name.
- Adds all files in the current directory to the new repository, excluding specified files in
.gitignore
. - Automatically generates a
.gitignore
file that excludes patterns such as*.csv
,*.xlsx
, environment files, and more, ensuring sensitive or unnecessary files are not committed. - Includes a
LICENSE
file with a predefined MIT license in the repository. - Commits the files to the repository.
- Configurable to use either HTTPS or SSH.
To use FastRepo, run the script in the directory you want to upload:
python fastrepo.py
Before running fastrepo.py
, ensure:
- A GitHub Personal Access Token (PAT) is obtained and set in your environment as
GITHUB_REPO_TOKEN
. - You have decided whether to include
.csv
and.xlsx
files in your project. By default, these files are ignored to prevent accidental upload of potentially sensitive data.
A GitHub Personal Access Token (PAT) is required to authenticate with the GitHub API and access private repositories. Follow these steps to generate a token:
- Log in to your GitHub account and navigate to the Settings page by clicking on your profile picture in the top-right corner and selecting Settings.
- In the left sidebar, click on Developer settings.
- Click on Personal access tokens in the left sidebar.
- Click the Generate new token button.
- Enter a name for the token in the Note field (e.g., "Repo-Prep").
- Select the appropriate scopes for the token. For the
fastrepo.py
script, the minimum required scope isrepo
(which grants full control of private repositories). You may need to select additional scopes depending on your use case. - Click the Generate token button at the bottom of the page.
In the fastrepo.py
script, replace the GITHUB_REPO_TOKEN
placeholder with your actual token or add it to the GITHUB_REPO_TOKEN
environment variable as detailed to automatically pull it from your environment.
- Add GitHub Personal Access Token to environment variable
GITHUB_REPO_TOKEN
-
Windows:
setx GITHUB_REPO_TOKEN "YourGitHubToken"
-
Linux:
echo 'export GITHUB_REPO_TOKEN="YourGitHubToken"' >> ~/.bashrc source ~/.bashrc
-
This ensures that your script can authenticate with GitHub to create the repository and push the initial commit.