git 将存储库克隆到 GitHub

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10346810/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:50:56  来源:igfitidea点击:

Clone repository into GitHub

gitgithubgit-clone

提问by cdmh

I have been using git locally for while a now and have a private repository with complete change history etc. I now want to share this on GitHub, so I need to clone from my local repo into a new GitHub repo. I cannot find any way to do this. How can I get all my history up onto GitHub?

我已经在本地使用 git 一段时间了,并且有一个包含完整更改历史记录等的私有存储库。我现在想在 GitHub 上共享它,所以我需要从我的本地存储库克隆到一个新的 GitHub 存储库。我找不到任何方法来做到这一点。如何将我的所有历史记录上传到 GitHub?

回答by Xion

You don't need to "clone onto GitHub". You just have to create a repository on GitHub and push your changes there:

您不需要“克隆到 GitHub”。您只需要在 GitHub 上创建一个存储库并将您的更改推送到那里:

$ cd your_local_repo
$ git remote add origin [email protected]:USERNAME/REPO_NAME.git
$ git push origin master

回答by Romain

You simply want to create a new repository on your account on GitHub. Assuming your account name is CraigH, and you call you new repository NewRepo(imaginative, I know), you'd simply (assuming you have GitHub keys set up on your system properly):

您只想在您的 GitHub 帐户上创建一个新存储库。假设您的帐户名为CraigH,并且您称您为新存储库NewRepo(我知道是富有想象力的),您只需(假设您在系统上正确设置了 GitHub 密钥):

  1. Add a remote to your local repository
  2. Push out your current history to GitHub
    • git push --set-upstream origin master
  1. 将远程添加到本地存储库
  2. 将您当前的历史记录推送到 GitHub
    • git push --set-upstream origin master

And from that point, your history in the masterbranch are in GitHub's masterbranch.

从那时起,您在master分支中的历史记录就在 GitHub 的master分支中。

回答by Martin Green

You do this by pushing to remote repo on GitHub. You should get the whole history and everything.

您可以通过推送到 GitHub 上的远程存储库来完成此操作。你应该得到整个历史和一切。