Search code examples
gitgithubgit-remote

Reconnect git local to GitHub remote without losing a new local branch and commits


With some help I managed to recover a local git project from a fatal: not a git repository (or any of the parent directories): .git issue... Why does git not recognise my local repository?

But now my local git is ahead on a new local branch (that doesn't exist on the GitHub remote) and is disconnected from the existing remote origin.

  • git remote -v returns nothing

How do I reconnect and push the local git to the existing GitHub remote without losing the new local branch with it's commits?


Solution

  • Add the remote:

    git remote add origin http://github.com/user/repo.git
    

    Then push the changes.