繁体   English   中英

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

[英]How to push github clone to new github repo?

我对自己的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并将其设置为默认推送分支。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM