Search code examples
gitrepository

Connect a local repository with a remote repository


I have a local repository. I created the whole application, but now I want to push it to a remote repository. I already have remote repo as well. How can I connect these two repositories without losing any work that I did?


Solution

  • Use:

    git remote add origin <remote_repo_URL>
    git push --all origin
    

    If you want to set all of your branches to automatically use this remote repository when you use git pull, add --set-upstream to the push:

    git push --all --set-upstream origin