New to git, so this is hopefully a simple question with a simple answer.
I forked a repository on GitHub. I then cloned it on my local machine by using the public repo URL: git@github.com:samuelclay/django-mingus.git
, as opposed to the private repo URL: git://github.com/samuelclay/django-mingus.git
.
I made some changes to the code, committed those changes, and in order to push my changes up to my forked repo, I issued: git remote add upstream git://github.com/samuelclay/django-mingus.git
, and then git push upstream
, but while that doesn't give me an error (it says Everything up-to-date), it is certainly not pushing my changes up to GitHub.
Is there a way to change to the private repo URL? Is that e开发者_运维技巧ven necessary?
I was able to easily do this by editing the .git/config file.
$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
So I edited .git/config
for that project and changed the origin's url:
[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
Success!
You've gotten the public and private URLs backwards. The git://
URL is the public one; the git@github
URL is the private one.
If you want to change a repo URL, just open up your .git/config
file in a text editor, find the offending URL, and change it to the other one. Check the git config
documentation for more information on the format of the config file.
精彩评论