博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git克隆github_如何使用Git和Github分叉,克隆和推送更改
阅读量:2506 次
发布时间:2019-05-11

本文共 3982 字,大约阅读时间需要 13 分钟。

git克隆github

介绍 (Introduction)

Github is an excellent resource for finding useful code. In order to contribute changes back to a project, you’ll need to make a local copy and then upload your changes. In this tutorial, you’ll fork and clone an existing repo, and then make changes to your local copy of the repo and push them back to Github.

Github是查找有用代码的绝佳资源。 为了将更改归还给项目,您需要制作本地副本,然后上传更改。 在本教程中,您将分叉并克隆现有的存储库,然后对存储库的本地副本进行更改,然后将其推回Github。

叉子和克隆 (Fork and Clone)

Go to the and click on Fork.

转到上的然后单击Fork

Fork will create a copy of the repository in your Github account so that you can make changes to the project.

Fork将在您的Github帐户中创建存储库的副本,以便您可以对项目进行更改。

Go to your own Github repository and you will see a repository named skeletonwebsite.

转到您自己的Github存储库,您将看到一个名为skeletonwebsite的存储库。

Click into this repository and we will now make a local copy of it on your machine by hitting the clone button.

单击进入此存储库,然后单击“克隆”按钮,我们将在您的计算机上对其进行本地复制。

Copy the Https URL.

复制Https URL

Open your terminal or git bash window.

打开终端或git bash窗口。

Move to the location on your computer where you want to create a copy of this project.

移动到计算机上要创建该项目副本的位置。

Run the following command:

运行以下命令:

git clone https://github.com/userid/skeletonwebsite.git

git clone https://github.com/ userid /skeletonwebsite.git

Substitute your Github username for userid.

用您的Github用户名替换userid。

You now have a local copy on your computer.

您现在在计算机上拥有本地副本。

The folder on your computer will have the same name as the remote repository on Github, skeletonwebsite

您计算机上的文件夹具有相同的名称为在Github远程仓库,skeletonwebsite

cd into skeletonwebsite.

cd进入skeletonwebsite。

Run thegit initcommand.

运行git init命令。

After running git init you should see a hidden git folder in your skeletonwebsite directory. If you don’t see it, change the settings on your computer to show hidden files and directories.

运行git init您应该在skeletonwebsite目录中看到一个隐藏的git文件夹。 如果看不到,请更改计算机上的设置以显示隐藏的文件和目录。

Now run git status to see the current status of your local repository. This will show if you have any commits that are staged or committed.

现在运行git status以查看本地存储库的当前状态。 这将显示您是否已暂存或落实任何提交。

Open up theindex.html file in your code editor.

在代码编辑器中打开index.html文件。

Add a heading or a paragraph.

添加标题或段落。

Now run git status.

现在运行git status

You should see that there are changes not staged to be committed with theindex.html file in red.

您应该看到没有将要暂存的更改用红色的index.html文件提交。

We will now add this change by running git add index.html. If you want to add multiple files at once then you can run git add . Run git status

现在,我们将通过运行git add index.html添加此更改。 如果要一次添加多个文件,则可以运行git add . 运行git status

Changes have now been staged and are ready to be committed.

现在已经进行了更改,可以进行更改了。

Now we can run git commit to commit these changes.

现在我们可以运行git commit来提交这些更改。

Use the-m flag to add a commit message.

使用-m标志添加提交消息。

Remember to describe the specific change you made in the git commit message.

记住要描述您在git commit消息中所做的特定更改。

Run git status again to check that everything is up to date.

Checking git status

再次运行git status以检查所有内容是否都是最新的。

This message shows everything is up to date.

此消息显示一切都是最新的。

We can now push our code to our repository on Github.

现在,我们可以将代码推送到Github上的存储库中。

Before we do this, run git remote -vto see what remote repository on Github our local repository is connected to.

Checking the remote repository

在执行此操作之前,请运行git remote -v以查看我们的本地存储库已连接到Github上的哪个远程存储库。

推送变更 (Push Changes)

Run git push origin master to push our changes to this repository.

运行git push origin master将我们的更改推送到此存储库。

Check that your remote repository has updated on Github

检查您的远程存储库在Github上是否已更新

结论 (Conclusion)

In this tutorial, you have successfully:

在本教程中,您已经成功地:

  1. Forked a repo.

    分叉了一个仓库。
  2. Cloned it to create a local repo on your computer.

    克隆它以在计算机上创建本地存储库。
  3. Made a change to the index.html file.

    对index.html文件进行了更改。
  4. Staged this change.

    进行此更改。
  5. Committed this change.

    进行了此更改。
  6. Confirmed what remote repo your local repo is connected to.

    确认您的本地存储库连接到哪个远程存储库。
  7. Successfully pushed your code to your forked repo on Github.

    成功将您的代码推送到Github上的分叉存储库中。

翻译自:

git克隆github

转载地址:http://txhgb.baihongyu.com/

你可能感兴趣的文章
apache下虚拟域名配置
查看>>
session和cookie区别与联系
查看>>
PHP 实现笛卡尔积
查看>>
Laravel中的$loop
查看>>
CentOS7 重置root密码
查看>>
Centos安装Python3
查看>>
PHP批量插入
查看>>
laravel连接sql server 2008
查看>>
Laravel框架学习笔记之任务调度(定时任务)
查看>>
laravel 定时任务秒级执行
查看>>
浅析 Laravel 官方文档推荐的 Nginx 配置
查看>>
Swagger在Laravel项目中的使用
查看>>
Laravel 的生命周期
查看>>
CentOS Docker 安装
查看>>
Nginx
查看>>
Navicat远程连接云主机数据库
查看>>
Nginx配置文件nginx.conf中文详解(总结)
查看>>
MySQL innert join、left join、right join等理解
查看>>
sdc时序约束
查看>>
NoC片上网络
查看>>