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.

  • How can I undo wrong permissions in my git working copy? Should I just clone again?
  • How to prepare clear diffs, when `git add --patch` edits are awkward?
  • SVN to Git using a fast import/export stream
  • What's the difference between bundling and zipping a git repo?
  • How do I connect a Jenkins slave to a Git server with self signed certificate?
  • Git Staged - It have file history?
  • Thanks.

  • github how to include files from master in new git branch gh-pages
  • Git repository is out of sync after rebase
  • Smallest, toy, Distributed version control system to study
  • How to clone a git repo with all branches and tags from refs/remotes?
  • How to get the git log of which files were deleted/modified?
  • What's the fastest way to edit hundreds of Git commit messages?
  • 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

    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

    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
    
    Git Baby is a git and github fan, let's start git clone.