简体   繁体   English

如何使用本地git仓库填充github仓库?

[英]How to populate a github repository with local git repository?

I Have a local git repository working without problem. 我有一个本地git存储库,没有问题。 However, I want to send this repository to populate a new repository on github. 但是,我想发送此存储库以在github上填充新的存储库。 Reading through github documentation I keep reading how to branch off a remote repository or how to push to a remote repository but not how to initially populate the remote repository. 仔细阅读github文档,我将继续阅读如何分支到远程存储库或如何推送到远程存储库,而不是如何最初填充远程存储库。 Thanks in advance 提前致谢

On local repository: 在本地存储库上:

git init git初始化

git add . git添加

git commit -m 'First commit' git commit -m'第一次提交'

git remote add origin remote_repository_URL git remote add origin remote_repository_URL

git remote -v git remote -v

git push origin master git push origin master

Please note that remote_repository_URL is the url of your newly created github repository. 请注意,remote_repository_URL是新创建的github存储库的URL。

First of all create a repository on github and note the url for that repository. 首先,在github上创建一个存储库,并记下该存储库的URL。 Now moce to your local repository and add new origin. 现在移动到本地存储库并添加新的来源。 With the command . 用命令。

git remote add origin paste/your/github/url

Now you can check the same with the command 现在您可以使用以下命令进行检查

git remote -v

if its reflecting or not. 是否反映出来。

Now just type command 现在只需键入命令

 git push origin master

and all local repository contents are moved to your Github repository. 并将所有本地存储库内容移至您的Github存储库。

Once you created the repo on github, just follow their instructions, which are like: 在github上创建存储库后,只需按照其说明进行操作即可,例如:

git remote add origin https://github.com/username/reponame.git
git push -u origin master

The question is little unclear, but still by 'initially populate', I assume you wish to create new repository. 这个问题尚不清楚,但是我仍然假设您想创建新的存储库。

Please read about it here: 请在这里阅读:
https://help.github.com/articles/create-a-repo/ https://help.github.com/articles/create-a-repo/

If you create a new repository on GitHub, they tell you what to do: 如果您在GitHub上创建新的存储库,那么它们会告诉您该怎么做:

git remote add origin git@github.com:your_username/your_repository_on_github.git
git push -u origin master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM