DEV Community

Cover image for Pushing Code to your GitHub account
Josiah Ngugi
Josiah Ngugi

Posted on

Pushing Code to your GitHub account

For my first article here I wanted to share with you how to push code to your GitHub account:

Before we get started here is a checklist of the necessary steps to setup your repository and configure git:

1) Create a GitHub account:

• If you don't already have one, sign up for a GitHub account at https://github.com/.

2) Install Git:

• Make sure Git is installed on your computer. You can download and install Git from the official Git website: https://git-scm.com/.

3) Configure Git:

• Set your Git username and email address using the following commands:
git config --global user.name "Your Name"
git config --global user.email “your.email@example.com

4) Create a new Repository:
• On GitHub, create a new repository by clicking on the "New" button in your repository list or visiting https://github.com/new.
• Choose a repository name, add a description (optional), select visibility (public or private), and initialize the repository with a README file if needed.

Let’s get Started!

First open your terminal and follow the given steps:

I. josiahngugi@Josiahs-Air ~ % pwd _used to get the current working directory _

II. josiahngugi@Josiahs-Air ~ % cd /Users/josiahngugi/Projects specify where the folder is located

III. josiahngugi@Josiahs-Air ~ % ls _specify the files inside the folder _

IV. josiahngugi@Josiahs-Air ~ % git init _initialize local directory as a git repo _

V. josiahngugi@Josiahs-Air ~ % git add . staging files for first commit (will add all files in that folder)

VI. josiahngugi@Josiahs-Air ~ % git status will see all the files you have staged for commit

VII. josiahngugi@Josiahs-Air ~ % git commit -m “First commit” committing files from local repo

Go back to GitHub repository quick setup page and copy the URL

VIII. josiahngugi@Josiahs-Air ~ % git remote add origin “paste url” add the url to the remote repo

IX. josiahngugi@Josiahs-Air ~ % git push -u origin master push code in local repo to GitHub

Go back to your GitHub account and refresh. There you have it, you're have just added your project on GitHub with all its folders.

Top comments (0)