Skip to content

Instantly share code, notes, and snippets.

@hpl002
Created November 28, 2020 14:43
Show Gist options
  • Save hpl002/cb414cb1d63364c0debb70f85ffd95bf to your computer and use it in GitHub Desktop.
Save hpl002/cb414cb1d63364c0debb70f85ffd95bf to your computer and use it in GitHub Desktop.

Prelude

While the git cli is expansive, it does not support creating new remote repositories directly from the terminal. Ref: forum post

We can however use hub to solve this slight annoyance..


  1. Install hub via your preferred package manager, instructions here

  2. Initialize a new git repo locally

        cd 
        mkdir my-new-repo; 
        cd my-new-repo
        git init
  3. add some content, stage file and commit

        touch yello.md        
        git add -A
        git commit . -m "init"
  4. create new repo on remote

     hub create #This will create a new repository on remote with name: my-new-repo 
    git push --set-upstream origin master #push to remote

Head over to github and check out your new repo: https://github.com

Cheers!

#!/bin/bash
# simple script that pushes the repo to remote
# to prevent any accidental action, you have to first manually initialize the git repo yourself with "git init"
#check if there exists any files at all, if not then create a readme
touch readme.md;
git add -A;
#write a comment that
git commit . -m "git repo initialized from script; init";
#check if there exists a repo under the same name
hub create;
git push --set-upstream origin master;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment