git 链接到现有的 GitHub 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19210371/
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
Link to existing GitHub repository
提问by blue-sky
I have created a repository on GitHub and would now would like commit changes to this repository using Git. I have a project file structure (created using Heroku) to be committed. What steps are required in order to link an existing GitHub repository with Git?
我在 GitHub 上创建了一个存储库,现在想使用 Git 提交对此存储库的更改。我有一个要提交的项目文件结构(使用 Heroku 创建)。将现有 GitHub 存储库与 Git 链接需要哪些步骤?
In the past I've used "GitHub for windows" UI to create a GitHub repository. This creates a file structure on my machine and as I update the file structure, the changes are recognised.
过去,我使用“GitHub for windows”UI 来创建 GitHub 存储库。这会在我的机器上创建一个文件结构,当我更新文件结构时,会识别更改。
But this new setup is a little different in that the project already exists, and I want to link it to a new GitHub repository.
但是这个新设置有点不同,因为该项目已经存在,我想将它链接到一个新的 GitHub 存储库。
回答by janos
You need to add a new remote, pointing to GitHub, and then push to it. The steps:
您需要添加一个新的远程,指向 GitHub,然后推送到它。步骤:
Create a repository on GitHub, without a README, completely empty.
In your existing repository:
git remote add REMOTENAME URL
. You could name the remotegithub
, for example, or anything else you want. Copy the URL from the GitHub page of the repository you just created.Push from your existing repository:
git push REMOTENAME BRANCHNAME
. For example, if you named your remotegithub
and you want to push master to it, you would dogit push github master
.
在 GitHub 上创建一个仓库,没有 README,完全空白。
在您现有的存储库中:
git remote add REMOTENAME URL
.github
例如,您可以命名遥控器或任何您想要的名称。从您刚刚创建的存储库的 GitHub 页面复制 URL。从现有存储库推送:
git push REMOTENAME BRANCHNAME
. 例如,如果你命名你的遥控器github
并且你想将 master 推送到它,你会做git push github master
.
Let me know if you need anything else.
需要帮助请叫我。