Skip to content

Instantly share code, notes, and snippets.

@daaronr
Created January 11, 2022 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daaronr/493373320c23439c26f210be3d1cb674 to your computer and use it in GitHub Desktop.
Save daaronr/493373320c23439c26f210be3d1cb674 to your computer and use it in GitHub Desktop.
Suprisingly easy to set up GH the CLI and make a repo ... Just some bash script and CLI responses

Setting up the Github terminal access -- 'gh cli' and setting up a repo

I waited a long time to try this, but it proved surprisingly easy

Install GitHub CLI, authenticate

In the bash terminal ... if you have brew installed on a Mac

$ brew install gh

All sorts of setup messages...

Next, before you can do anything, you need to authenticate.

Any command will probably lead to the message

To authenticate, `please run gh auth login`

OK, so let's do it

$ gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? SSH
? Upload your SSH public key to your GitHub account? /Users/yosemite/.ssh/github_rsa.pub
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: [CODE IS HERE]
- Press Enter to open github.com in your browser...

Web browser opens and I enter that code.

Note: This only worked because I had setup this SSH public key thing previously. That's how you have to get into GitHub these days.

Initialize a git repo on your machine

You probably know how to set up a git repo in the terminal. Go to the folder you want to make a git repo.

$ git init
$ g init
$ g commit -m "first commit, adding about half of the 'munging' content from functions.R so far"

Set up a 'remote' on GitHub for this repo (at your organization, if you like), and push it

$ gh repo create

? What would you like to do? Push an existing local repository to GitHub

? Path to local repository .

? Repository name rethinkpriorities/r-noodling-package

? Description package of commands for dynamically working with data, not producing output

? Visibility Public

\✓ Created repository rethinkpriorities/r-noodling-package on GitHub

? Add a remote? Yes

? What should the new remote be called? origin

✓ Added remote git@github.com:rethinkpriorities/r-noodling-package.git

? Would you like to push commits from the current branch to the "origin"? Yes

✓ Pushed commits to git@github.com:rethinkpriorities/r-noodling-package.git

Note, I largely selected the default options (given in parens in the interface) above.

Note the organization came before the repo name in rethinkpriorities/r-noodling-package

This repo, an R-package thing, is now up here

@daaronr
Copy link
Author

daaronr commented Jan 11, 2022

This gist was set up with the command:

gh gist create --public making_gh_repo_with_cli.md -d "Suprisingly easy to set up GH the CLI and make a repo ... Just some bash script and CLI responses"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment