DEV Community

Cover image for Push First Project to Github (First use of Git Bash)
Mustapha DABELLA
Mustapha DABELLA

Posted on

2

Push First Project to Github (First use of Git Bash)

Today I will guide you to push your own local files to your GitHub as Repository so here simple steps:

1- First of all, you have to create a GitHub account if you don't have one, then log in, after that you have to create your new repository.

2- Give a Name to your repository (don't check: Initialize this repository with README.md if you want to add your own README) and click Create Repository.

3- Download and install Git Bash and during installation, you can choose options that you prefer.

4- Launch Git Bash Command Line and change the current directory to the location of your project files using this command: "cd"
Example: cd /Desktop/Projects/ProjectToPushToGithub

5- Type this command "git init" (without double quotes) and hit enter and you will get a new folder named ".git".

6- Run this command: git remote add origin UrlOfYourRepository
Example: git remote add origin https://github.com/mustaphadabella/BookPage.git

7- Run This Command: git push -u origin master
If you get an error like this:
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/mustaphadabella/BookPage.git'

Solution of the error:

Run this command: git add -A

8- Run This Command to commit: git commit -m 'initial commit'

9- Next Run This Command: git push -u origin master
note: if it's your first time a popup will display to login to your Github Account so you enter your email and password to log in to your account.

10- Finally, Check your GitHub account you will find all your project files in your Repository.
I hope this article was useful for you and HAPPY CODING!

Top comments (1)

Collapse
 
dmredhat profile image
DMredHat β€’

Simple and Clear steps thanks

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs