git 推/拉git时出现错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20953552/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I have error when push/pull git
提问by Arthur Yakovlev
I am created my exists project from local files. But this project exists in git repository. And now i need commit changes in project and pull/push his, but git don't know what is repository i have master or origin. This is error message:
我从本地文件创建了我的现有项目。但是这个项目存在于 git 存储库中。现在我需要在项目中提交更改并拉/推他的,但 git 不知道我拥有的存储库或来源是什么。这是错误信息:
fatal: No remote repository specified. Please, specify either a URL or a
remote name from which new revisions should be fetched.
Thanks!
谢谢!
回答by Christopher Ellis
If you initially cloned your repository then:
如果您最初克隆了您的存储库,则:
git push origin master
If you are wanting to push local files to an empty repository you created on github, then:
如果您想将本地文件推送到您在 github 上创建的空存储库,则:
git remote add origin [email protected]:username/reponame.git
You have to have a connection established to communicate properly. Hereis a more detailed answer to help.
您必须建立连接才能正常通信。 这是一个更详细的帮助答案。
Hereis a good Git tutorial site.
这是一个很好的 Git 教程站点。
EDIT: "You push your local repository to the remote repository using the git push command after first establishing a relationship between the two with the git remote add command. If you visit your Github repository, it will show you the URL to use for pushing. You'll first enter something like:
编辑:“首先使用 git remote add 命令建立两者之间的关系后,您使用 git push 命令将本地存储库推送到远程存储库。如果您访问您的 Github 存储库,它将向您显示用于推送的 URL。您将首先输入以下内容:
git remote add origin [email protected]:username/reponame.git
"
git remote add origin [email protected]:username/reponame.git
”
Replace [email protected]:username/reponame.git
with the URL from the repository. The URL is located on the right side bar, titled "SSH clone URL".
替换[email protected]:username/reponame.git
为存储库中的 URL。URL 位于右侧栏,标题为“SSH 克隆 URL”。
回答by Mingsheng
For people whose remotes are already set...
对于已经设置好遥控器的人...
If you wish to set tracking information for this branch you can do so with:
如果您希望为此分支设置跟踪信息,您可以这样做:
git branch --set-upstream-to=<remote>/<branch> <local branch>
This would allow you to simply run "git pull"instead of "git pull origin branch"
这将允许您简单地运行“git pull”而不是“git pull origin branch”