如何将 github 克隆推送到新的 github 存储库

  • 本文关键字:github 存储 git github
  • 更新时间 :
  • 英文 :


我制作了自己的 github 存储库的本地克隆,对其进行了不同的项目,现在我想将其作为新存储库推送到 github。我被迫首先在 github 上创建一个空白存储库,然后推送到它,因为似乎不可能通过推送它来创建新的存储库。现在,当我这样做时,我收到一条常见的错误消息:

remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to matc
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

将远程(空)存储库克隆到虚拟分支(其他地方的建议)在这里不起作用,我也无法修改远程存储库的设置。我不想强迫任何事情,我希望历史清楚,曾经是另一个 github 存储库。

我还尝试分叉原始的 github 存储库,并与之合并,但是在 github 上分叉我自己的存储库没有任何作用。

实现我想要的东西的最佳/最干净方法是什么?

您需要首先在本地存储库中注册一个存储库(您在 github 上创建的空白存储库)。

$ git remote add another_repo git@github.com:XXX.git

然后你可以推送到这个仓库

$ git push -u another_repo master

你试过吗:

$ git push --set-upstream origin master

它将创建远程分支master并将其设置为默认推送分支。

最新更新