DEV Community

Shawon Saha
Shawon Saha

Posted on

Upload existing project to github repository through command line

At first create a repo from your github account

alt text

Now head back to the folder you want to push to github. It'll look something like this in terminal ~/foldername$. Now Type and run

git init
Enter fullscreen mode Exit fullscreen mode

This command will create a hidden folder .git

Head back to terminal and type

git add .
Enter fullscreen mode Exit fullscreen mode

Remember to put the (dot). This will make all your file in that folder to be committed.

At this point you have to configure your name and email to run commit command.

git config --global user.email "you@example.com"

git config --global user.name "Your Name"
Enter fullscreen mode Exit fullscreen mode

Replace Your Name and email and run the commands separately.

Now you are ready to be committed

git commit -m "Your Commit Message"
Enter fullscreen mode Exit fullscreen mode

Head back to browser and go inside your newly created repo again. You'll find a link like this pattern https://github.com/username/repository-name.git
If you don't find tap on Clone or download and copy the link. Make sure 'https' is selected not 'ssl'

In terminal type

git remote add origin https://github.com/username/repository-name.git
Enter fullscreen mode Exit fullscreen mode

Then run

git push -u origin master
Enter fullscreen mode Exit fullscreen mode

Now Put your github username and password

Top comments (0)