A command-line tool that creates a new GitHub project using another repository as a template, automatically handling cloning, remote configuration, and optional pushing to a new repository.
StartFromRepo streamlines the process of starting new projects from existing repository templates. Instead of manually cloning, changing remotes, and pushing to new repositories, this tool handles the entire workflow in a single command.
When starting new projects, developers often want to reuse existing repository structures that include:
- Preconfigured
.devcontainersetups - Build scripts and CI/CD workflows
- Project scaffolding and utilities
- Development tooling configuration
This tool automates the tedious process of cloning a template repository and setting it up with a new remote origin, optionally pushing the code to a new GitHub repository in one step.
- ✅ Clone any GitHub repository as a template
- ✅ Automatically reconfigure git remote to point to new repository
- ✅ Rename default branch to
main - ✅ Optional automatic push to GitHub (requires pre-created empty repository)
- ✅ Uses existing git credentials (no additional authentication required)
- ✅ Comprehensive logging with color-coded output
- ✅ Cross-platform support (Linux, macOS, Windows)
dotnet run --project src/startfromrepo/startfromrepo.csproj -- --username <github-username> --source <source-repo> --destination <destination-repo>./StartFromRepo --username <github-username> --source <source-repo> --destination <destination-repo>Clone a repository and set up new remote:
dotnet run --project src/startfromrepo/startfromrepo.csproj -- \
--username myusername \
--source template-repo \
--destination my-new-projectClone and automatically push to a pre-created GitHub repository:
dotnet run --project src/startfromrepo/startfromrepo.csproj -- \
--username myusername \
--source template-repo \
--destination my-new-project \
--pushdotnet run --project src/startfromrepo/startfromrepo.csproj -- \
-u myusername \
-s template-repo \
-d my-new-project \
-p| Parameter | Short | Description | Required | Default |
|---|---|---|---|---|
--username |
-u |
GitHub username | Yes | - |
--source |
-s |
Source repository name to clone | Yes | - |
--destination |
-d |
Destination repository name | Yes | - |
--push |
-p |
Push to GitHub after cloning | No | false |
The tool uses your existing git credentials configured on your system. Ensure you have one of the following configured:
- Git Credential Manager (recommended for HTTPS)
- SSH Keys configured with GitHub
- GitHub CLI (
gh) authentication
Verify your git configuration:
git config --get user.name
git config --get user.emailWhen using the --push flag:
- The tool checks if the destination repository exists on GitHub
- If it exists, the code is automatically pushed to
origin/main - If it doesn't exist, you'll receive instructions to create the repository manually
Important: Create an empty GitHub repository at https://github.com/<username>/<destination> before using --push.
Main entry point that handles:
- Command-line argument parsing using
System.CommandLine - Orchestration of the cloning and pushing workflow
- User feedback through the logging utility
Git operations wrapper providing:
VerifyGitCredentialsAsync()- Validates git configurationCloneRepositoryAsync()- Clones source repositoryChangeGitOriginAsync()- Updates remote origin and ensuresmainbranchCheckRepositoryExistsAsync()- Verifies GitHub repository existencePushCodeToRepositoryAsync()- Pushes code to remote repositoryExecuteGitCommandAsync()- Low-level git command execution
Console logging utility with color-coded output:
LogInfo()- White text for informational messagesLogError()- Red text for error messagesLogDebug()- Yellow text for debug information
User Input → Parse Arguments → Verify Git Credentials
↓
Clone Source Repository → Change Remote Origin → Rename to 'main'
↓
(Optional) Check Repository Exists → Push to GitHub
↓
Success/Error Feedback
- .NET 9.0 SDK
- Git
- GitHub account with configured credentials
# Restore dependencies
dotnet restore src/startfromrepo.sln
# Build in Debug mode
dotnet build src/startfromrepo.sln
# Build in Release mode
dotnet build src/startfromrepo.sln --configuration ReleaseThe project includes xUnit tests for core functionality:
# Run all tests
dotnet test src/Tests/startfromrepo.Tests.csproj
# Run with verbose output
dotnet test src/Tests/startfromrepo.Tests.csproj --verbosity normalTest files:
GitTests.cs- Tests for Git utility functionsProgramTests.cs- Tests for main program logicLoggingTests.cs- Tests for logging utility
Create self-contained executables that don't require .NET runtime installation:
dotnet publish src/startfromrepo/startfromrepo.csproj \
-c Release \
-r linux-x64 \
--self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=truedotnet publish src/startfromrepo/startfromrepo.csproj \
-c Release \
-r win-x64 \
--self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=truedotnet publish src/startfromrepo/startfromrepo.csproj \
-c Release \
-r osx-arm64 \
--self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=truedotnet publish src/startfromrepo/startfromrepo.csproj \
-c Release \
-r osx-x64 \
--self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=truePublished binaries will be located in: src/startfromrepo/bin/Release/net9.0/<runtime-id>/publish/
The project uses GitHub Actions for continuous integration:
- Workflow:
.github/workflows/ci.yml - Triggers: Pull requests and pushes to
mainbranch - Jobs:
- Restore NuGet packages with caching
- Build solution in Release mode
- Run xUnit test suite
startfromrepo/
├── src/
│ ├── startfromrepo/
│ │ ├── Program.cs # Main entry point
│ │ ├── GitCliUtility.cs # Git operations wrapper
│ │ ├── LoggingUtility.cs # Console logging utility
│ │ ├── startfromrepo.csproj # Project file
│ │ └── global.json # .NET SDK version
│ ├── Tests/
│ │ ├── GitTests.cs # Git utility tests
│ │ ├── ProgramTests.cs # Program logic tests
│ │ ├── LoggingTests.cs # Logging tests
│ │ └── startfromrepo.Tests.csproj
│ └── startfromrepo.sln # Solution file
├── .github/
│ ├── workflows/
│ │ └── ci.yml # CI/CD workflow
│ └── prompts/ # Custom Copilot prompts
├── .devcontainer/ # Dev container configuration
└── README.md
- System.CommandLine (2.0.0-beta) - Modern command-line parsing
- xUnit (2.6.6) - Unit testing framework
- .NET 9.0 - Target framework
This repository includes a preconfigured devcontainer for .NET C# development with:
- .NET 9.0 SDK
- VS Code C# extensions
- Git and GitHub CLI tools
- Pre-installed global .NET tools
- Open this repository in VS Code
- When prompted, click "Reopen in Container"
- The devcontainer will build with a fully configured development environment
For detailed instructions, see .devcontainer/README.md.
See LICENSE for details.
Contributions are welcome! Please ensure:
- All tests pass:
dotnet test - Code builds without warnings:
dotnet build - Follow existing code style and patterns
Current version: 0.4.0