If on a local branch, how should I push that repo to remote from local repo that already exists?
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.
2 Solutions collect form web for “If on a local branch, how should I push that repo to remote from local repo that already exists?”
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
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
Remember that before pushing your repository to GitHub you need to commit your changes:
git commit -m "My last changes"
Then you need to create empty project on GitHub without readme nor gitignore file.
To send your code to github you shall add remote(which is your empty github project) to your local repository:
git remote add origin <github project url>
At last you should push your state of repository to remote:
git push origin master