git 将本地仓库与远程仓库连接起来
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11188801/
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
connect local repo with remote repo
提问by Om3ga
I have a local repo. I created the whole app but now I want to push it to remote repo. I already have remote repo as well. How can I connect these two repos without losing any work that I did?
我有一个本地仓库。我创建了整个应用程序,但现在我想将它推送到远程仓库。我也已经有了远程仓库。如何在不丢失我所做的任何工作的情况下连接这两个存储库?
回答by vergenzt
git remote add origin <remote_repo_url>
git push --all origin
If you want to set all of your branches to automatically use this remote repo when you use git pull
, add --set-upstream
to the push:
如果要在使用时将所有分支设置为自动使用此远程存储库git pull
,请添加--set-upstream
到推送中:
git push --all --set-upstream origin
回答by バカです
I know it has been quite sometime that you asked this but, if someone else needs, I did what was saying here " How to upload a project to Github" and after the top answer of this question right here. And after was the top answer was saying here "git error: failed to push some refs to" I don't know what exactly made everything work. But now is working.
我知道你问这个问题已经有一段时间了,但是,如果其他人需要,我做了这里所说的“如何将项目上传到 Github”,并在此问题的最佳答案之后。之后是最重要的答案是在这里说“ git error: failed to push some refs to”我不知道究竟是什么让一切正常。但现在正在工作。