If you have existing projects or files already and want to push/publish it on github repo, but not familiar with the git commands for it then following steps will make you complete your task within a minutes.
Step 1:- First of all visit your github dashboard and then create a repo either private or public but don’t initiate with README and any License Templates,and then click create new repository button, after that you will be redirected to Quick Set up Page, now copy the project URL with HTTPS option.
Step 2:- Open Terminal and then change the directory to your working or project Directory.
Step 3:- Initialize your local project as a Git Repository with
$git init .
Step 4:- Add the file to a repository with $git add . , This adds the files of your local repository to staging for your initial commit.
Step 5:- Commit the files that you have added or staged in your local repository with $git commit -m “your commit message”.
Step 6:- Now add the URL of your remote repository that you have copied from Quick Setup Page with $git remote add origin < your remote repository URL> and then verify it with $git remote -v .
Step 7:- Now Push your staged files to remote repository with $git push origin master
After that, you will be asked for Github username and password please provide those credentials, as soon as you enter your password, your local project starts pushing to Github.