create-github
v1.0.10
Published
a command-line tool to quickly initialize a Git repository and push it to GitHub
Readme
create-github
create-github is a command-line tool to quickly initialize a Git repository and push it to GitHub. With simple interactive prompts, you can complete all steps from initializing the Git repository to pushing your code.
Features
- Automatically generates a
.gitignorefile (if it doesn't exist). - Supports interactive initialization of a Git repository (
git init). - Supports interactively adding files to the staging area (
git add .). - Supports interactively committing code (
git commit). - Supports setting up a remote repository address (
git remote add origin). - Supports pushing code to a specified branch (
git push -u origin <branch>). - Provides friendly command-line prompts and error handling.
- Cross-platform support: Automatically detects the operating system and generates appropriate Git commands for Windows (PowerShell) and Unix/Linux systems.
Installation and Usage
Option 1: Run Directly with npm init
You can use the following command to initialize a GitHub repository directly:
npm init githubThis command will prompt you through the steps to initialize a Git repository and push it to GitHub.
Option 2: Run Directly with npm create
Alternatively, you can use the shorter npm create syntax:
npm create githubThis command works similarly to npm init github and provides the same functionality.
Example
$ npm create github
Welcome to create-github - Quickly initialize a Git repository and push to GitHub
.gitignore file created successfully
Execute git init? (default: y): y
git init executed successfully
Execute git add .? (default: y): y
git add . executed successfully
Enter commit message (default: Initial commit): First commit
git commit executed successfully
Enter GitHub repository URL: https://github.com/your-repo.git
Enter branch name (default: main): main
git remote added successfully
Execute git push to main branch? (default: y): y
git push to main branch successful
Operation completed!Cross-Platform Support
The tool automatically detects the operating system and generates appropriate Git commands:
- Windows: Uses PowerShell commands.
- Non-Windows: Uses Unix/Linux shell commands.
For example, the following script is added to package.json:
"scripts": {
"git": "powershell -Command \"$msg = Read-Host 'Enter commit message'; git add .; git commit -m \\\"$msg\\\"; git push\""
}Configuration File
The TypeScript configuration file tsconfig.json contains the following settings:
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"typeRoots": ["node_modules/@types"],
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.test.ts"]
}Ensure that TypeScript and Node.js type definitions are installed correctly:
npm install --save-dev typescript @types/nodeContribution Guidelines
We welcome issues and pull requests! If you'd like to contribute to the project, please follow these steps:
- Fork this repository.
- Create your feature branch (
git checkout -b feature/YourFeatureName). - Commit your changes (
git commit -m 'Add some feature'). - Push your branch (
git push origin feature/YourFeatureName). - Submit a Pull Request.
License
This project is licensed under the MIT License.
