A simple bash script to initialize a git repository and create a corresponding GitHub repository in one command.
- Initializes a local git repository (or uses an existing one with
-e) - Creates a
.gitignorefile with common patterns - Makes an initial commit if needed
- Authenticates with GitHub if needed
- Creates a private GitHub repository by default (use
-pfor public) - Pushes your code to GitHub
- All with a single command
- GitHub CLI (gh) must be installed
- Ubuntu/Debian:
sudo apt install gh - macOS:
brew install gh - Other platforms: See GitHub CLI installation
- Ubuntu/Debian:
- Clone or download this repository
- Make the script executable:
chmod +x init.sh
- Optionally, move it to a directory in your PATH for easy access:
sudo mv init.sh /usr/local/bin/init
Navigate to your project directory and run:
./init.shImportant: The GitHub repository will be named after your current directory. For example, if you run the script in /home/user/my-project/, the repository will be created as my-project.
-p- Create a public repository (default is private)-e- Use existing.gitrepository (skipgit init)-h- Show help message
Create a private repository:
./init.shCreate a public repository:
./init.sh -pCreate a repo for an existing .git directory:
./init.sh -e- Checks if the directory is already a git repository (exits if so, unless
-eis used) - Checks if GitHub CLI is installed
- Authenticates with GitHub (prompts if not authenticated)
- Checks if a repository with that name already exists on GitHub (exits if so)
- Initializes git (skipped with
-e) - Creates a
.gitignorefile if one doesn't exist - Makes an initial commit if needed
- Creates a GitHub repository with the same name as your directory
- Sets up the remote and pushes your code
- Displays the URL of your new repository
- If a
.gitignorefile already exists, it won't be overwritten - The script will exclude itself (
init.sh) from being committed - For public repos, planning files (
PRD.md,progress.txt) and.claude/are automatically added to.gitignore