How to add Project to GitHub from command line

GitHub Learning | CMD

Mausam Singh
1 min readNov 22, 2020

Step 1: Create a new repository in GitHub.

I. Go to your command prompt or git cmd and change directory to working project in your local computer/laptop.

cd <pathofprojectDirectory>example : cd /home/usr/new_project

Step 2: Initialize the local project directory as git repository

git init

Step 3: Add the file into local repository and wait few seconds if project size is large.

git add .

or

git add --all

Step 4: Now, commit the files you have added into local repository.

git commit -m "comment about addition/changes you have done"

Step 5: Now, copy the remote repository URL field from GitHub repository and paste it in the place of remote repository URL.

From code section(blue color) copy the remote repository URL from your repository
git remote add origin <remote repository URL>

Step 6: Now, check and set the new remote

git remote -v

Final step 7: Now, push the changes into GitHub from local repository.

git push origin mastergit push -f origin master      // In case first one doesn't working
git push -u -f origin master // try this also

It’s done, Go and checkout your repository from GitHub.

--

--

Mausam Singh

Aspiring Product Manager | Android Developer | Ex-SDE at Meesho | I believe in writing for self reflection and reading for self development.