Paul Duca Paul Duca - 3 months ago 9
Git Question

If on a local branch, how should I push that repo to remote from local repo that already exists?

I am pretty new to programing/git and am trying to learn best practice.
If I have a repo I created on my computer, what is the best way to make that a repo on github.

I have been creating on github for the most part and would like to know what the practice would be if I wanted/needed to do it in reverse.

Thanks.

Answer

You need to create repository on GitHub first. To avoid confusion create it with the same name you already have to your repository.

Change the current working directory

cd project_folder

Assuming you have initialized your repository and committed some files using:

git init
git add .
git commit -m "First commit"

Copy the newly created repository URL and add remote using this command:

git remote add origin remote_repository_URL

push to remote repository

git push origin master 
# master here is your branch 

Follow this link for detailed steps