如何使用 Ubuntu 命令行拉取已上传到 Git 的项目?

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

How do you use the Ubuntu command line to pull a project that's been uploaded onto Git?

gitubuntucommand-line

提问by Kaitlyn Mcmordie

I (think) I've set up Git correctly. How do I pull my friend's project that he's shared with me so that I can help him with it?

我(认为)我已经正确设置了 Git。我如何提取他与我共享的朋友的项目,以便我可以帮助他?

回答by Ben Lee

By "uploaded onto Git" I assume you mean "uploaded onto GitHub". That's an important distinction: Git is a source control system. GitHub is a place to host repositories that are controlled via git.

通过“上传到 Git”,我假设您的意思是“上传到 GitHub”。这是一个重要的区别:Git 是一个源代码控制系统。GitHub 是托管通过 git 控制的存储库的地方。

To clone a repository that is hosted on GitHub, first log into your github account and go to the main page (https://github.com/). Off to the right, just under the tiles at the top will be a section labeled "Your Repositories". The one your friend shared with you should be listed. Click on it. Then near the top of this new page, you'll see a git clone url like "[email protected]:abc/xyz.git". Copy this and then run the command:

要克隆托管在 GitHub 上的存储库,首先登录到您的 github 帐户并转到主页 ( https://github.com/)。在右侧,顶部的磁贴下方将是一个标有“您的存储库”的部分。您的朋友与您分享的那个应该被列出。点击它。然后在这个新页面的顶部附近,你会看到一个 git clone url,如“[email protected]:abc/xyz.git”。复制这个,然后运行命令:

git clone [email protected]:abc/xyz.git

回答by Joe

Assuming you're trying to clone a repository from GitHub, you will need to follow these steps:

假设您尝试从 GitHub 克隆存储库,您需要执行以下步骤:

  1. Get the HTTPS URL of the repo as shown in this screenshot
  2. On a terminal window type the command (be sure to enter the URL you copied in step 1):

    git clone HTTPS_URL_COPIED_IN_STEP_1.git

  3. If you are asked for your GitHub username & password enter them now. Please note that the username is notyour email address.

  1. 获取 repo 的 HTTPS URL,如此屏幕截图所示
  2. 在终端窗口中键入命令(确保输入您在步骤 1 中复制的 URL):

    git clone HTTPS_URL_COPIED_IN_STEP_1.git

  3. 如果系统要求您提供 GitHub 用户名和密码,请立即输入。请注意,用户名不是您的电子邮件地址。

If you have 2-factor authentication turned on, you'll need to create a personal access token first.Your regular password will not work if you use 2-factor authentication on GitHub.

如果您打开了 2 因素身份验证,则需要先创建个人访问令牌。如果您在 GitHub 上使用 2 因素身份验证,您的常规密码将不起作用。

Follow the instructions hereto create the token. Once this is done, enter this in place of the password after step 2.

按照此处的说明创建令牌。完成此操作后,请在步骤 2 后输入该密码来代替密码。

回答by redrider

try this:

尝试这个:

git pull origin <branch>