Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all build test clean clean-cache clean-all run lint lint-fix coverage coverage-ci install ci
.PHONY: all build test clean clean-cache clean-all run lint lint-fix coverage coverage-ci install ci test-clean test-smoke

# Default target
all: build
Expand Down Expand Up @@ -50,3 +50,24 @@ ci: clean-all lint test build
# Install the CLI tool
install:
go install .

# Remove temporary smoke-test directories created under /tmp
test-clean:
rm -rf /tmp/fake-svelte /tmp/fake-repo /tmp/smoke-node /tmp/smoke-go /tmp/smoke-svelte
@echo "Cleaned up /tmp smoke-test directories."

# Dry-run smoke tests for all v1.2.0 features (no GitHub required)
test-smoke: install
@echo "--- Test: --no-license ---"
gitstart -d /tmp/smoke-node --no-license --dry-run
@echo "--- Test: --no-readme ---"
gitstart -d /tmp/smoke-node --no-readme --dry-run
@echo "--- Test: --post-framework (Node auto-detect) ---"
mkdir -p /tmp/fake-svelte && touch /tmp/fake-svelte/package.json
gitstart -d /tmp/fake-svelte --post-framework --dry-run
@echo "--- Test: branch auto-detection ---"
mkdir -p /tmp/fake-repo/.git && echo 'ref: refs/heads/develop' > /tmp/fake-repo/.git/HEAD
touch /tmp/fake-repo/package.json
gitstart -d /tmp/fake-repo --post-framework --dry-run
@echo "--- Cleaning up ---"
$(MAKE) test-clean
104 changes: 89 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

Gitstart automates creating a GitHub repository. It will:

- Create `.gitignore` if you provide a language
- Auto-detect project language and create `.gitignore` (or use `-l` to specify)
- Create a license file based on your choice
- Create a new repository at GitHub.com (public or private)
- Create a `README.md` file with the repository name
- Initialize a git repository (if needed)
- Auto-detect the active branch from an existing repo
- Add files and commit with a custom message
- Add the remote and push
- Support existing directories and projects
Expand Down Expand Up @@ -84,22 +85,64 @@ cd existing_project
gitstart -d .
```

### Options
### After a Framework Starter

gitstart works seamlessly after scaffolding tools like `npx sv create`, `npm create vite@latest`, or `composer create-project`. Use `--post-framework` to skip prompts for files the framework already created, while still auto-detecting the language and branch:

```sh
npx sv create my-app && cd my-app && gitstart -d . --post-framework
npm create vite@latest my-app && cd my-app && gitstart -d . --post-framework
composer create-project laravel/laravel my-app && cd my-app && gitstart -d . --post-framework
npx nuxi@latest init my-app && cd my-app && gitstart -d . --post-framework
```

Or use quiet mode for a minimal one-liner:

```sh
npx sv create my-app && cd my-app && gitstart -d . -q
```

### Options

```text
-d, --directory DIRECTORY Directory name or path (use . for current directory)
-l, --language LANGUAGE Programming language for .gitignore
-l, --language LANGUAGE Programming language for .gitignore (auto-detected if omitted)
-p, --private Create a private repository (default: public)
-P, --public Create a public repository
-b, --branch BRANCH Branch name (default: main)
-b, --branch BRANCH Branch name (auto-detected from existing repo; default: main)
-m, --message MESSAGE Initial commit message (default: "Initial commit")
--description DESC Repository description
--no-license Skip LICENSE file creation
--no-readme Skip README.md creation
--post-framework Optimised for use after a framework starter
(implies --no-license --no-readme)
-n, --dry-run Show what would happen without executing
-q, --quiet Minimal output
-h, --help Show help message
version Show version
```

### Language Auto-detection

When `-l` is not provided and no `.gitignore` exists, gitstart inspects the project directory for well-known marker files and infers the language automatically:

| Marker file(s) | Detected language |
|---|---|
| `go.mod` | Go |
| `Cargo.toml` | Rust |
| `pubspec.yaml` | Dart |
| `composer.json` | Composer (PHP) |
| `Gemfile` | Ruby |
| `pom.xml`, `build.gradle`, `build.gradle.kts` | Java |
| `requirements.txt`, `pyproject.toml`, `setup.py`, `setup.cfg` | Python |
| `package.json` | Node |

If multiple markers are present the first match in the table above wins. You can always override auto-detection with `-l`.

### Branch Auto-detection

When `--branch` is not explicitly set and a `.git` directory already exists (e.g. created by a framework starter), gitstart reads the active branch from `.git/HEAD` and pushes to that branch instead of defaulting to `main`. Passing `--branch` explicitly always takes precedence.

### Examples

**Create a new repository:**
Expand Down Expand Up @@ -127,6 +170,19 @@ gitstart -d my-app -m "First release" -b develop
gitstart -d awesome-tool --description "An amazing CLI tool for developers"
```

**Skip LICENSE and README (e.g. framework already created them):**
```sh
cd my-existing-project
gitstart -d . --no-license --no-readme
```

**Use --post-framework after a Svelte scaffold:**
```sh
npx sv create my-app
cd my-app
gitstart -d . --post-framework
```

**Preview changes without executing (dry run):**
```sh
gitstart -d test-repo --dry-run
Expand Down Expand Up @@ -184,7 +240,7 @@ gitstart completion powershell >> $PROFILE

### Working with Existing Directories

**Empty directory:** Creates repository normally
**Empty directory:** Creates repository normally.

**Directory with files but no git:**
- Warns about existing files
Expand All @@ -194,33 +250,33 @@ gitstart completion powershell >> $PROFILE

**Directory with existing git repository:**
- Detects existing `.git` folder
- Auto-detects the active branch from `.git/HEAD`
- Adds remote to existing repository
- Preserves git history

**Existing LICENSE, README.md, or .gitignore:**
- Detects existing files
- Offers to append or skip
- Prevents accidental overwrites
- Detects existing files and skips them
- Use `--no-license` or `--no-readme` to explicitly suppress creation
- Use `--post-framework` to suppress both at once

### Interactive License Selection

When you run gitstart, you'll be prompted to select a license:
When you run gitstart without `--no-license`, `--post-framework`, or `-q`, you'll be prompted to select a license:

```
```text
Select a license:
1) MIT: I want it simple and permissive.
2) Apache License 2.0: I need to work in a community.
3) GNU GPLv3: I care about sharing improvements.
1) mit: Simple and permissive
2) apache-2.0: Community-friendly
3) gpl-3.0: Share improvements
4) None
5) Quit
```

## Error Handling

- **Automatic cleanup**: If repository creation fails, the remote repository is automatically deleted
- **Validation checks**: Ensures all required tools are installed
- **Auth verification**: Confirms you're logged in to GitHub
- **File conflict detection**: Warns about existing files before overwriting
- **File conflict detection**: Detects existing files and skips safely
- **Detailed error messages**: Clear information about what went wrong and how to fix it

## About Licensing
Expand All @@ -229,6 +285,24 @@ Read more about [Licensing](https://docs.github.com/en/free-pro-team@latest/rest

## Changelog

### Version 1.2.0

**New Features:**
- Auto-detect project language from marker files (`go.mod`, `package.json`, `Cargo.toml`, etc.) when `-l` is not provided
- `--no-license` flag to skip LICENSE creation without suppressing all output
- `--no-readme` flag to skip README.md creation without suppressing all output
- `--post-framework` flag: optimised mode for use after framework starters — implies `--no-license --no-readme`
- Auto-detect active branch from `.git/HEAD` when `--branch` is not explicitly set

**Bug Fixes:**
- Fixed dry-run language detection to always auto-detect (not only when `--post-framework` is set)
- Fixed `composer.json` marker mapping from `PHP` to `Composer` (PHP.gitignore does not exist in GitHub/gitignore)
- Renamed internal `resolvDir` to `resolveDir` (typo fix)

### Version 1.1.0

- Added shell completion support (bash, zsh, fish, PowerShell)

### Version 1.0.0 (2026)

Gitstart is now rewritten in Go with full cross-platform support (macOS, Linux, Windows).
Expand Down
Loading