将本地更改从当前存储库推送到 GitHub 中创建的全新存储库

Pushing local changes from current repository to completely new repo created in GitHub

我一直在为 GitHub 的存储库中托管的应用程序在本地进行更改。现在我想将我在本地添加的所有更改推送到我在 GitHub 中创建的全新存储库中。当我尝试将本地更改推送到这个全新的 repo 时,我收到错误消息:

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

现在,我会毫不犹豫地 git 从我的新存储库中提取,因为我怀疑它会清除我的本地更改。

我应该如何将更改推送到新的存储库?

没有必要犹豫做git pull <new_repo> master 然后git push <new_repo> master。这是将更改推送到远程仓库的最安全方法。 git pull 不会消除本地更改,它所做的任何事情都是可逆的。

关闭此线程。