git克隆github_如何使用Git和Github分叉,克隆和推送更改

news/2024/7/3 6:49:33

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 Skeletonwebsite repository on Github and click on Fork.

转到Github上的Skeletonwebsite存储库,然后单击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上的分叉存储库中。

翻译自: https://www.digitalocean.com/community/tutorials/fork-clone-make-changes-push-to-github

git克隆github


http://www.niftyadmin.cn/n/3649259.html

相关文章

LBS模块架构的封装

对地图进行一个封装 public interface ILbsLayer {/*** 获取地图*/View getMapView();/*** 设置位置变化监听*/void setLocationChangeListener(CommonLocationChangeListener locationChangeListener);/*** 设置定位图标*/void setLocationRes(int res);/*** 添加&#xf…

[收藏]张翼轸:在Outlook的名义下

张翼轸:在Outlook的名义下 -------------------------------------------------------------------------------- http://www.sina.com.cn 2005年03月08日 14:48 ChinaByte   文/张翼轸Plaxo、Teleo、Skype这几个不同的SNS(Social Network Software,…

如何构建和安装Go程序

介绍 (Introduction) So far in our How To Code in Go series, you have used the command go run to automatically compile your source code and run the resulting executable. Although this command is useful for testing your code on the command line, distributing…

如何得到包含隐藏API的Android类库

Android SDK的很多API是隐藏的,我无法直接使用。但是我们通过编译Android系统源码可以得到完整的API库。编译Android系统源码后可以在out\target\common\obj\JAVA_LIBRARIES目录中有它所有API库(java)。当然对于一般情况,out\target\common\obj\JAVA_LIB…

ISO9001:2000和能力成熟度模型的集成

ISO9001:2000和能力成熟度模型的集成 ISO9001:2000and the Capability Maturity ModelIntegration 原作者: Angela Tuffley and Terence P.Rout Software Quality Institute, Griffith University; Mark Stone-Tolcher and Ian Gray, Defence Materiel Organisati…

[收藏]用社会网络分析改进知识的创新与共享

用社会网络分析 (Social Network Analysis ; SNA) 改进知识的创新与共享 作者: Rob Cross,Andrew Parker , Steve Borgatti 摘要一个人获得知识的环境,就是人际关系经常影响一个人获取知识的管道。社会网路分析(Social Network An…

java常用排序算法(一)

冒泡排序算法 比较相邻的元素。如果第一个比第二个大,就交换他们两个。对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对。在这一点,最后的元素应该会是最大的数。针对所有的元素重复以上的步骤,除了最后一个。 相同元…

如何下载Android源码(window和Linux)

文章参照来源:http://source.android.com/source/downloading.html 一、window平台关于在window平台下载Android源码,网上一般使用的是直接用git来下载。比如:http://wenku.baidu.com/view/a4f5f922482fb4daa58d4bb5.htmlhttp://hendyyou.ite…