如何将github克隆推送到新的github repo?

时间:2012-11-12 07:56:45

标签: git github

我做了一个我自己的github repo的本地克隆,做了一个不同的项目,现在我想把它作为一个新的回购推送到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'.

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

我也尝试分叉原始的github仓库,并与之合并,但在github上分配我自己的仓库并没有做任何事情。

达到我想要的最好/最干净的方法是什么?

2 个答案:

答案 0 :(得分:4)

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

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

然后你可以推送到这个回购

$ git push -u another_repo master

答案 1 :(得分:0)

你试过了吗?

$ git push --set-upstream origin master

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