我是Git/GitHub的新手,遇到了一个问题.我创建了一个测试项目并将其添加到本地存储库中.现在我正在尝试将文件/项目添加到远程存储库.
这就是我所做的(这有效) -
git remote add origin git://github.com/my_user_name/my_repo.git
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试将存储库推送到GitHub时,使用以下命令,我收到以下错误 -
git push origin master
Run Code Online (Sandbox Code Playgroud)
错误 -
fatal: remote error:
You can't push to git://github.com/my_user_name/my_repo.git
Use git@github.com:my_user_name/my_repo.git
Run Code Online (Sandbox Code Playgroud)
Mar*_*air 242
GitHub不支持推送Git协议,这可以通过使用URL开头来表示git://
.正如错误消息所示,如果要推送,则应使用GitHub为您的存储库显示git@github.com:my_user_name/my_repo.git
的https://
URL 使用SSH URL 或"智能HTTP"协议.
(更新:令我惊讶的是,有些人显然认为通过这个我建议"https"意味着"智能HTTP",我不是.Git曾经有一个"哑的HTTP"协议,不允许推送之前"智能HTTP"即GitHub的用途引入-要么可以在使用任一http
或https
可以通过GIT中所使用的传输协议之间的差别在下面的链接进行说明)
如果要更改原始URL,您可以执行以下操作:
git remote set-url origin git@github.com:my_user_name/my_repo.git
Run Code Online (Sandbox Code Playgroud)
要么
git remote set-url origin https://github.com/my_user_name/my_repo.git
Run Code Online (Sandbox Code Playgroud)
更多信息可在10.6 Git Internals - Transfer Protocols中找到.
Abd*_*bdo 37
使用Mark Longair的答案,但请确保使用HTTPS链接到存储库:
git remote set-url origin https://github.com/my_user_name/my_repo.git
Run Code Online (Sandbox Code Playgroud)
你可以用git push origin master
.
Pur*_*ket 13
Mark Longair的解决方案使用git remote set-url...
非常明确.您也可以通过直接编辑.git/config文件的此部分来获得相同的行为:
之前:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git://github.com/my_user_name/my_repo.git
Run Code Online (Sandbox Code Playgroud)
后:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:my_user_name/my_repo.git
Run Code Online (Sandbox Code Playgroud)
(相反,git remote set-url...
调用会产生上述变化.)
归档时间: |
|
查看次数: |
101552 次 |
最近记录: |