create-github-repo-from-commandline

How to create Github Repository from command line

In this post I am going to describe creating Repo on Github via Command line

Here is to go:

  1. Create local folder in your desktop (e.g. Windows)
  2. Create your code file (s) in this directory
  3. Install git if you haven’t install it
  4. start command prompt from start menu and cd to your local folder
  5. run git init (>git init).
  6.  >git commit -m “Add existing file”  to add all your files to local git repo.
  1. Step 1: Install Git. …
  2. Step 2: Open a Terminal or Command Prompt. …
  3. Step 3: Navigate to Your Local Folder,  where your local code files exist (or you want to create later)
  4. Step 4: Initialize a Git Repository, by command >git init
  5. Step 5: Add Files to the Staging Area, by command >git add .
  6. Step 6: Commit Changes, by command: >git commit -m ” your commit”
  7. Step 7: Create a New Repository on GitHub, go  to your Github and create a new Repo by pressing to the New button then  give a name to your Repo (it is better the name shall be the same folder name in your local folder)
  8. Step 8: set URL to your Repo on Github by command : > git remote set-url origin https://github.com/yourGithub-id/your-repo (e.g. git remote set-url origin https://github.com/mehzan07/healthcheck)
  9. Step 9: Branch create your branch on Github by command: >git branch -M main

10.Step 10 Push your files to Github by command: >git push -u origin main

Now you have all local files in the Github, you can Create a ReadMe.md file

Conclusion 

In this post we have showed how to create a local git repo and push it to a github Repo by command line.

This post was part of Topics

Back to home page