使用forked git存储库,但我克隆了公共repo URL,而不是私有URL

时间:2010-01-16 03:49:26

标签: git github

git的新手,所以希望这是一个简单回答的简单问题。

我在GitHub上分叉了一个存储库。然后,我使用公共存储网址git@github.com:samuelclay/django-mingus.git将其克隆到我的本地计算机上,而不是私有存储网址:git://github.com/samuelclay/django-mingus.git

我对代码进行了一些更改,提交了这些更改,并且为了将我的更改推送到我的分叉回购,我发布了:git remote add upstream git://github.com/samuelclay/django-mingus.git,然后是git push upstream,但是虽然没有给我一个错误(它说一切都是最新的),它当然没有把我的更改推到GitHub。

有没有办法更改为私人仓储网址?这甚至是必要的吗?

2 个答案:

答案 0 :(得分:8)

我可以通过编辑.git / config文件轻松完成此操作。

$git clone git://github.com/user/test.git # Clone from read only
# Make changes
$ git push
fatal: remote error: 
  You can't push to git://github.com/user/test.git
  Use git@github.com:user/test.git

所以我为该项目编辑了.git/config并更改了原点的网址:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    # Remove this line:
    #url = git://github.com/user/test.git
    # Add this line:
    url = git@github.com:user/test.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
$ git push
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 298 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To git@github.com:user/test.git
   58986b8..c8bd8c2  master -> master

成功!

答案 1 :(得分:3)

您已经向后获取了公共和私人网址。 git://网址是公开网址; git@github网址是私人网址。

如果您想更改repo URL,只需在文本编辑器中打开.git/config文件,找到有问题的URL,然后将其更改为另一个。有关配置文件格式的更多信息,请查看git config文档。

相关问题