How to Create a repository and Push on Github with Git

Smith Vyne
Sep 7, 2018 · 3 min read
The GitHub Join Page

To create a repository…

  1. You have to first install git from this link
  2. Follow the right installation instructions for your OS
  3. Next, on your GitHub account click on the + icon next to your avatar(assuming you have already created one here)
  4. Select “New repository”
  5. In the page that opens input your repository name; select public; then select to initialize with a README.

Congratulations, your repository is now created

A GitHub Repository Page

Next Steps:

  1. Click the green button on the top-left corner of the section that reads “Clone or download”
  2. Copy the link to your repository, you’d need it when cloning
  3. Now, open git bash on your computer and change directory to where you’d like the cloned version of your repository to be.
  4. On that directory, type in:

$ git clone https://github.com/your.username/your.repo.git [paste link here] Enter

You should see something like…

Cloning into ‘your.repo’…
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.

Means it worked just fine :)


Setting Username and Email Configurations

$ git config user.name

$git config user.email

The two commands above are what you’ll use to set your git username and email for your current directory. For a global configuration see here for instructions. To set your name and email configurations, use:

$ git config user.name “your.username”

$git config user.email “your.email”

Now run the first commands above to make sure the configurations have been set appropriately. If so, your usernames and passwords would display appropriately.

Next Steps: Staging, Committing, then Pushing:

  1. Move the file you wish to push to the current directory of the cloned repository.
  2. In the git bash console, enter; $git add .
  3. Next, enter; $ git commit -m “Your.file.name
  4. Next, enter $git push origin master$ git push origin master

You’d see something like

Username for ‘https://github.com': your.username
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 3.96 KiB | 1.98 MiB/s, done.
Total 6 (delta 0), reused 0 (delta 0)
To https://github.com/user.name/your.repo.git
fb87647..804d302 master -> master

What you should see

Means your file has been pushed to the remote repository :)

Now, What??


Hurray, now your file has been pushed to the remote repository. You could check up your GitHub repository through the browser. :]

Note: There are a few other ways to push your code to GitHub, but this article is meant to be minimal and straightforward. So, if you want to have more alternatives read up more here and here.

If this article was helpful, I would love you let me know with a clap or more. Also, it’ll ensure more people get to see this article.

Smith Vyne

Written by

For my Love for today.. I Code, Read, Write, and Listen to Nature

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade