将 git 本地重新连接到 GitHub 远程而不丢失新的本地分支并提交

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

在一些帮助下,我设法从 fatal: not a git repository (or any of the parent directories): .git 问题中恢复了本地 git 项目...

但是现在我的本地 git 在一个新的本地分支上领先(在 GitHub 远程上不存在)并且与现有的远程源断开连接。

如何重新连接本地 git 并将其推送到现有的 GitHub 远程而不丢失新的本地分支及其提交?

添加遥控器:

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

然后推送更改。