<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tyler Turnipseed</title>
    <description>The latest articles on DEV Community by Tyler Turnipseed (@techturnip).</description>
    <link>https://dev.to/techturnip</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F153952%2Fc7f05f3f-155e-4e30-b6fe-47d726f1846f.jpg</url>
      <title>DEV Community: Tyler Turnipseed</title>
      <link>https://dev.to/techturnip</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/techturnip"/>
    <language>en</language>
    <item>
      <title>GitHub CLI - How to Create a Repo from your Terminal</title>
      <dc:creator>Tyler Turnipseed</dc:creator>
      <pubDate>Wed, 07 Oct 2020 01:02:51 +0000</pubDate>
      <link>https://dev.to/techturnip/github-cli-how-to-create-a-repo-from-your-terminal-1aeg</link>
      <guid>https://dev.to/techturnip/github-cli-how-to-create-a-repo-from-your-terminal-1aeg</guid>
      <description>&lt;h1&gt;
  
  
  Getting Started with GitHub CLI
&lt;/h1&gt;

&lt;h2&gt;
  
  
  How to Install GH CLI
&lt;/h2&gt;

&lt;p&gt;Before we can use the CLI we have to get it installed on our machines.&lt;/p&gt;

&lt;p&gt;Refer to this &lt;a href="https://github.com/cli/cli#installation"&gt;README&lt;/a&gt; for specific installation instructions for your OS including Windows and MacOS.&lt;/p&gt;

&lt;p&gt;Personally, Pop!_OS (Linux) is my preferred OS so I'll be sharing the Linux instructions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/cli/cli/blob/trunk/docs/install_linux.md"&gt;Linux Instructions Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For me getting started was as simple as running a few commands in the terminal!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install gh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This should work for most Debian based distros like Ubuntu and Pop!_OS&lt;/p&gt;

&lt;p&gt;Next you can confirm your installation by running the &lt;code&gt;gh&lt;/code&gt; command with the &lt;code&gt;--version&lt;/code&gt; flag&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gh --version
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Let's Create a Repo!
&lt;/h2&gt;

&lt;p&gt;Once the CLI is installed we can easily create a repo on GitHub directly within a project on our local machine.&lt;/p&gt;

&lt;p&gt;While this works for any project that can be managed with GitHub, I'm gonna run through the steps to quickly get a React application created with CRA and pushed up to GitHub.&lt;/p&gt;

&lt;p&gt;First we need to create a project in whatever directory we would like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# change directory to where you want to generate the project
cd whatever/path/you/like/

# generate a react application in that directory
npx create-react-app my-project

# change directory into the new project
cd my-project/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now that we have a project set up we and because CRA initializes a local git repo for us, all we have to do is create a GitHub repo to host our project.&lt;/p&gt;

&lt;h2&gt;
  
  
  But First, Authentication
&lt;/h2&gt;

&lt;p&gt;We are ready to leverage the GitHub CLI, but before we can reap the benefits of this tool, we need to authenticate with GitHub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cli.github.com/manual/"&gt;Check out all the documentation here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run this command to login to GH from your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gh auth login
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You'll be prompted to select either &lt;code&gt;GitHub.com&lt;/code&gt; or &lt;code&gt;GitHub Enterprise Server&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GitHub.com&lt;/code&gt; should be selected by default, just hit enter.&lt;/p&gt;

&lt;p&gt;Next, it will ask how you would like to authenticate.&lt;/p&gt;

&lt;p&gt;Here you can paste in a token, if you've already set up SSH access for your device, by selecting the &lt;code&gt;Paste an authentication token&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;Otherwise, you can select the default &lt;code&gt;Login with a web browser&lt;/code&gt; option and it will give you an access code and open up your default web browser. That's the option I'll be selecting for this tutorial.&lt;/p&gt;

&lt;p&gt;Hit enter and you will be presented with a one-time access code that you will need to copy. Copy it and then press enter and your browser will open up to a screen so you can paste in your code.&lt;/p&gt;

&lt;p&gt;After you enter your code, you will then have to authorize the cli application to give it full access to your GitHub. &lt;/p&gt;

&lt;p&gt;Once you click authorize, back in the terminal, it will ask if you want to use &lt;code&gt;https&lt;/code&gt; or &lt;code&gt;ssh&lt;/code&gt;, I would just select &lt;code&gt;https&lt;/code&gt; for now. It just means you'll have to type your login/password when you push up your repo.&lt;/p&gt;

&lt;p&gt;Once you've selected &lt;code&gt;https&lt;/code&gt; you're done and you are now ready to use the GitHub CLI&lt;/p&gt;

&lt;h2&gt;
  
  
  Back to our project
&lt;/h2&gt;

&lt;p&gt;At this point we should have the GitHub CLI installed and we should have authenticated our device with our account on GitHub.&lt;/p&gt;

&lt;p&gt;We can finally create a repo from our terminal, and perform many other GitHub tasks!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cli.github.com/manual/gh_repo_create"&gt;Checkout the docs for this feature&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's prepare our local repo, so it is ready to be pushed up to GitHub. Likely, there will be nothing to commit, that's okay. This is just a precautionary step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .
git commit -m "initial commit"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we can create a remote GitHub repo to host our project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gh repo create my-project
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You will then be prompted to select either &lt;code&gt;Public&lt;/code&gt;, &lt;code&gt;Private&lt;/code&gt;, or &lt;code&gt;Internal&lt;/code&gt;. Go ahead and select the default &lt;code&gt;Public&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;It will then warn you that it will create your 'my-project' repo with your current directory go ahead and type in &lt;code&gt;Y&lt;/code&gt; and press enter.&lt;/p&gt;

&lt;p&gt;You should now see something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✓ Created repository yourusername/my-project on GitHub
✓ Added remote https://github.com/yourusername/my-project.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;gh repo create&lt;/code&gt; command should have already configured our remotes for us so all we need to do is push our code up:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# git defaults to the "master" branch we can change it
# before we push up our project
git checkout -b main

# this will be our default branch on GitHub
git push origin main
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After issuing the push command, simply login with your GitHub credentials and we are done!&lt;/p&gt;

&lt;p&gt;Go to &lt;a href="https://www.github.com/"&gt;GitHub&lt;/a&gt; to check out the repo you just created from your terminal!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The GitHub CLI is an awesome tool that makes things like creating repos and submitting PRs a breeze, all from your terminal! I highly suggest you take a look at the documentation for a deeper dive into its capabilities.&lt;/p&gt;

&lt;p&gt;I hope you have found this article to be helpful, let me know what I can improve upon or if you have any issues getting up and running with GitHub CLI!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>github</category>
      <category>development</category>
      <category>git</category>
    </item>
  </channel>
</rss>
