github/create-from-local
Creates a new Github repository and pushes the local git folder to that repo, configuring the repo as git origin in the local repository in the process.
Usage
npx @lukasbach/scripts github/create-from-local
You can call the script directly if you have installed it globally:
npm i -g @lukasbach/scripts
ldo github/create-from-local
Arguments
[0]
: Repository name
Options
--push
: Do you want to push local changes as initial commit?-v
,--verbose
: Verbose logging
You can also omit options, and will be asked for them interactively.
Add --yes
to skip all confirmations.
Script source
/** Creates a new Github repository and pushes the local git folder to that repo, configuring the repo as
* git origin in the local repository in the process. */
import * as path from "path";
utils.assert(await fs.exists(".git"), "Not a git repository");
const repoName = await ask.text("_", "Repository name", path.basename(process.cwd()));
await $({ stdio: "inherit" })`gh repo create ${repoName} --private --source .`;
if (await ask.bool("push", "Do you want to push local changes as initial commit?")) {
await $`git add .`;
await $`git commit -m "Initial commit"`;
await $`git push`;
}