Skip to main content
Lesson 7 ยท GitHub track 2 min readBeginner๐Ÿ’ป Terminal

Create Repo Via Command line

In this tutorial, you will learn how to create a GitHub repository and push your first files to it from the command line.

You are here15 lessons in the GitHub track

Prerequisitesโ€‹

  1. You should have a GitHub account.
  2. You should have a basic understanding of how Git works and ensure Git is installed and running on your operating system.

Your checklist

Tick each step as you finish it.
0 of 2 done

Step 1: How to create Github Repositoryโ€‹

1. Go to GitHub and create a new Repository.

https://github.com

GitHub


2. Specify the name of your project, make it public or private, check the option to include a README file. Then click on Create repository on the button below.

https://github.com/new

GitHub

Once the repository is created, you'll see a screen similar to the one below, the explanation for each element is provided below.

create a new repository on the command line
echo "# demo-repo" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/sanjay-kv/demo-repo.git
git push -u origin main
https://github.com/sanjay-kv/demo-repo

GitHub

Step 2: Browser Renderingโ€‹

https://github.com/sanjay-kv/demo-repo

GitHub

https://github.com/sanjay-kv/demo-repo

GitHub

https://github.com/sanjay-kv/demo-repo

GitHub

Now you can see the new file has been added to your local system

https://github.com/sanjay-kv/demo-repo

GitHub

10. Once the work is done, click save and open cmd or Terminal

https://github.com/sanjay-kv/demo-repo

GitHub

11. Initially when I was creating the repo I used Git add * to add all files in one go.

If you are committing for the first time, Git may prompt you to enter your GitHub email id and username to proceed. The screenshot below shows an example of the prompt. After entering these details, when you run the git push command, a browser window may open asking you to sign in to GitHub.

create a new repository on the command line
git config --global user.email "Enter your github Email"
git config --global user.name "Github username"

Watch the video Tutorialโ€‹

Conclusionโ€‹

In this tutorial, you created a repository on GitHub, then used Git on the command line to add a file, commit it and push it to the remote repository.

UP NEXT ยท LESSON 8How to clone repository
Share this page

MAINTAINED BY

Sanjay Viswanathan

@sanjay-kv

Founder of recodehive and Technical program manager, Prev Google ML Facilitator & Ex- GitHub CE who delivered 100+ talks on ML and open source and developer advocacy.

Was this helpful?

Your vote helps us improve our docs.

Improve this page

All our docs are open source. Found a typo, want to add detail or have a better explanation? Anyone can contribute.

Comments

Powered by GitHub Discussions