<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Git简明教程 on 重定向学院</title><link>https://itest2025.pages.dev/categories/git%E7%AE%80%E6%98%8E%E6%95%99%E7%A8%8B/</link><description>Recent content in Git简明教程 on 重定向学院</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Tue, 17 Jun 2025 17:29:15 +0800</lastBuildDate><atom:link href="https://itest2025.pages.dev/categories/git%E7%AE%80%E6%98%8E%E6%95%99%E7%A8%8B/index.xml" rel="self" type="application/rss+xml"/><item><title>（一）认识Git与GitHub</title><link>https://itest2025.pages.dev/tutorials/33-001-%E4%B8%80%E8%AE%A4%E8%AF%86git%E4%B8%8Egithub/</link><pubDate>Thu, 31 Aug 2017 06:00:11 +0800</pubDate><guid>https://itest2025.pages.dev/tutorials/33-001-%E4%B8%80%E8%AE%A4%E8%AF%86git%E4%B8%8Egithub/</guid><description>&lt;h4 id="git的诞生">Git的诞生&lt;/h4>
&lt;p>Linus Torvalds在1991年创建了开源系统Linux，在2002年以前，世界各地的志愿者把源代码文件通过diff的方式发给Linus，然后由Linus本人通过手工方式合并代码！然后，Linux系统已经发展了十年了，代码库之大让Linus很难继续通过手工方式管理了。&lt;/p>
&lt;p>于是，Linus Torvalds花了两周时间自己用C写了一个分布式版本控制系统，这就是Git！一个月之内，Linux系统的源码已经由Git管理了！&lt;/p>
&lt;h4 id="git介绍">Git介绍&lt;/h4>
&lt;p>Git是一个开源的分布式版本控制系统，用以有效、高速地处理从很小到非常大的项目版本管理。相比CVS、SVN等版本控制工具，Git无疑更加优秀，功能更加强大，在项目版本管理中被越来越多的人广泛的使用。但 Git 相对来说比较难学。&lt;/p>
&lt;p>使用Git来管理项目有两种方式：&lt;/p>
&lt;ul>
&lt;li>
&lt;p>一种是本地部署Git版本管理系统。&lt;/p>
&lt;/li>
&lt;li>
&lt;p>另一种是通过在线代码托管。&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>本地部署Git版本管理系统，需要自己来搭建环境，但项目的提交与更新速度快，更适合较为封闭的项目；使用在线托管最大的好处是在有网络的情况下可以随时随地提交自己的代码，但项目是公开的，当然也可以创建私有项目，大多属于付费服务。&lt;/p>
&lt;h4 id="github">GitHub&lt;/h4>
&lt;p>GitHub就是基于Git的在线代码托管平台。&lt;/p>
&lt;p>GitHub为当前最流行的开源项目托管平台，数以万计优秀的开源项目被托管在GitHub上面。随着越来越多的应用程序转移到云上，Github已经成为了管理软件开发以及发现已有代码的首选方法。对于普通开发人员来讲，其在GitHub上托管的项目已经成为了他的一张个人名片。许多优秀的互联网公司在招聘开发人员时都希望对方能提供个人的GitHub地址。当然，GitHub作为一个开源软件的大宝库，学习和使用它，也会为我们的日常开发带来许多便利。&lt;/p>
&lt;h4 id="测试为什么学习git-">测试为什么学习Git ？&lt;/h4>
&lt;ul>
&lt;li>工作需要&lt;/li>
&lt;/ul>
&lt;p>我们工作中需要对项目代码进行管理，我的工作中就先后使用了SVN和Git对项目的版本进行管理。所以，这是测试人员必备技能。&lt;/p>
&lt;ul>
&lt;li>学习需要&lt;/li>
&lt;/ul>
&lt;p>你工作中所使用的编程语言的第三方库，大量都在GitHub上面托管，要想安装这些库就会用到Git；另外一些主流的Selenium、Appium开源项目也都是在GitHub上进行维护。&lt;/p>
&lt;ul>
&lt;li>个人名片&lt;/li>
&lt;/ul>
&lt;p>将你自己工作中的一些项目和代码放到GitHub上面进行管理。这无疑是对个人能力最好的展示。&lt;/p>
&lt;p>原始封面&lt;/p>
&lt;p>&lt;img
 class="lazyload"
 src="https://itest2025.pages.dev/svg/loading.min.svg"
 data-src="https://images.unsplash.com/photo-1580894732930-0babd100d356?w=300"
 data-srcset="https://images.unsplash.com/photo-1580894732930-0babd100d356?w=300, https://images.unsplash.com/photo-1580894732930-0babd100d356?w=300 1.5x, https://images.unsplash.com/photo-1580894732930-0babd100d356?w=300 2x"
 data-sizes="auto"
 alt="https://images.unsplash.com/photo-1580894732930-0babd100d356?w=300"
 title="课程图片" />&lt;/p></description></item><item><title>（二）GitHub注册与Git安装</title><link>https://itest2025.pages.dev/tutorials/33-002-%E4%BA%8Cgithub%E6%B3%A8%E5%86%8C%E4%B8%8Egit%E5%AE%89%E8%A3%85/</link><pubDate>Thu, 31 Aug 2017 03:00:11 +0800</pubDate><guid>https://itest2025.pages.dev/tutorials/33-002-%E4%BA%8Cgithub%E6%B3%A8%E5%86%8C%E4%B8%8Egit%E5%AE%89%E8%A3%85/</guid><description>&lt;h4 id="注册github">注册GitHub&lt;/h4>
&lt;hr>
&lt;p>GitHub官方地址：https://github.com。&lt;/p>
&lt;p>在浏览器中打开GitHub网址，通过首页进行注册，如下图所示。&lt;/p>
&lt;p>&lt;img
 class="lazyload"
 src="https://itest2025.pages.dev/svg/loading.min.svg"
 data-src="http://img.testclass.net/github_page.png"
 data-srcset="http://img.testclass.net/github_page.png, http://img.testclass.net/github_page.png 1.5x, http://img.testclass.net/github_page.png 2x"
 data-sizes="auto"
 alt="http://img.testclass.net/github_page.png"
 title="http://img.testclass.net/github_page.png" />&lt;/p>
&lt;h4 id="安装git">安装Git&lt;/h4>
&lt;hr>
&lt;p>Git官方下载地址：http://git-scm.com/download/。&lt;/p>
&lt;p>Git支持多平台（Mac OS X/Windows/Linux/Solaris）,读者可根据自己的平台选择相应的版本下载。&lt;/p>
&lt;p>Linux 各版本下安装Git：&lt;/p>
&lt;pre>&lt;code> Debian/Ubuntu $ apt-get install git-core

 Fedora $ yum install git

 Gentoo $ emerge --ask --verbose dev-vcs/git

 Arch Linux $ pacman -S git
&lt;/code>&lt;/pre>
&lt;p>下载并安装完成后，我们通常在Mac OSX及Linux平台下用终端工具(Terminal)来使用Git，而在Windows平台下用Git Bash工具，如下图所示。&lt;/p>
&lt;p>&lt;img
 class="lazyload"
 src="https://itest2025.pages.dev/svg/loading.min.svg"
 data-src="http://img.testclass.net/git_menu.png"
 data-srcset="http://img.testclass.net/git_menu.png, http://img.testclass.net/git_menu.png 1.5x, http://img.testclass.net/git_menu.png 2x"
 data-sizes="auto"
 alt="http://img.testclass.net/git_menu.png"
 title="http://img.testclass.net/git_menu.png" />&lt;/p>
&lt;h4 id="建立链接">建立链接&lt;/h4>
&lt;hr>
&lt;p>本地Git与GitHub服务器之间保持通信时，我们使用SSH key认证方式来保证通信安全，所以在使用GitHub前你必须先建创自已的SSH key。
我们后续操作以Windows为例，打开Git Bash，如下图所示。&lt;/p>
&lt;p>&lt;img
 class="lazyload"
 src="https://itest2025.pages.dev/svg/loading.min.svg"
 data-src="http://img.testclass.net/git_window.png"
 data-srcset="http://img.testclass.net/git_window.png, http://img.testclass.net/git_window.png 1.5x, http://img.testclass.net/git_window.png 2x"
 data-sizes="auto"
 alt="http://img.testclass.net/git_window.png"
 title="http://img.testclass.net/git_window.png" />&lt;/p></description></item><item><title>（三）Git提交代码到GitHub</title><link>https://itest2025.pages.dev/tutorials/33-003-%E4%B8%89git%E6%8F%90%E4%BA%A4%E4%BB%A3%E7%A0%81%E5%88%B0github/</link><pubDate>Thu, 31 Aug 2017 02:00:11 +0800</pubDate><guid>https://itest2025.pages.dev/tutorials/33-003-%E4%B8%89git%E6%8F%90%E4%BA%A4%E4%BB%A3%E7%A0%81%E5%88%B0github/</guid><description>&lt;p>请先阅读：&lt;a href="https://itest2025.pages.dev/git/registration-and-installation/" rel="">GitHub注册与Git安装&lt;/a>&lt;/p>
&lt;h4 id="github创建项目">GitHub创建项目&lt;/h4>
&lt;hr>
&lt;p>在GitHub选择并创建一个项目。首先，登录 GitHub，单击页面右上角加号__“+”__ ，选择__“New repository”__ 选项。&lt;/p>
&lt;p>填写项目名称及描述，默认项目为“Public”,如果想创建“Private”项目，GitHub需要收费。最后单击“Create repository”完成项目的创建，如下图所示。&lt;/p>
&lt;p>项目名称为：&lt;strong>project-name&lt;/strong>&lt;/p>
&lt;p>&lt;img
 class="lazyload"
 src="https://itest2025.pages.dev/svg/loading.min.svg"
 data-src="http://img.testclass.net/git_create_project.png"
 data-srcset="http://img.testclass.net/git_create_project.png, http://img.testclass.net/git_create_project.png 1.5x, http://img.testclass.net/git_create_project.png 2x"
 data-sizes="auto"
 alt="http://img.testclass.net/git_create_project.png"
 title="http://img.testclass.net/git_create_project.png" />&lt;/p>
&lt;p>创建完一个项目之后，GitHub会提示我们如何提交项目到它上面。&lt;/p>
&lt;pre>&lt;code>Quick setup — if you’ve done this kind of thing before
HTTPS https://github.com/defnngj/project-name.git
SSH git@github.com:defnngj/project-name.git

…or create a new repository on the command line

echo # project-name &amp;gt;&amp;gt; README.md
git init
git add README.md
git commit -m &amp;quot;first commit&amp;quot;
git remote add origin git@github.com:defnngj/project-name.git
git push -u origin master

…or push an existing repository from the command line

git remote add origin git@github.com:defnngj/project-name.git
git push -u origin master

…or import code from another repository

You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
&lt;/code>&lt;/pre>
&lt;h4 id="第一次提交代码到github">第一次提交代码到GitHub&lt;/h4>
&lt;hr>
&lt;p>首先进行初始化配置：设置仓库人员的用户名和邮箱地址，这一步必不可少。&lt;/p></description></item><item><title>（四）Git克隆与更新代码</title><link>https://itest2025.pages.dev/tutorials/33-004-%E5%9B%9Bgit%E5%85%8B%E9%9A%86%E4%B8%8E%E6%9B%B4%E6%96%B0%E4%BB%A3%E7%A0%81/</link><pubDate>Thu, 31 Aug 2017 02:00:11 +0800</pubDate><guid>https://itest2025.pages.dev/tutorials/33-004-%E5%9B%9Bgit%E5%85%8B%E9%9A%86%E4%B8%8E%E6%9B%B4%E6%96%B0%E4%BB%A3%E7%A0%81/</guid><description>&lt;p>请先阅读：&lt;/p>
&lt;p>&lt;a href="https://itest2025.pages.dev/git/registration-and-installation/" rel="">GitHub注册与Git安装&lt;/a>&lt;/p>
&lt;p>&lt;a href="https://itest2025.pages.dev/git/git-commit-code/" rel="">通过Git提交代码到GitHub&lt;/a>&lt;/p>
&lt;h4 id="克隆项目">克隆项目&lt;/h4>
&lt;hr>
&lt;p>我们除了可以向GitHub上提交项目外，更多的时候是我们到上面克隆（下载）优秀的开源项目来用，当然也可以将使用过程中发现的bug，通过建立分支的方式提交给项目的原作者。
我们现在的场景是在家将项目提交到了GitHub上，现在来到公司，需要将GitHub上的项目克隆到本地，那么对于公司的电脑来说，同样需要与GitHub建立连接。&lt;/p>
&lt;p>首先，下载安装Git。&lt;/p>
&lt;p>其次，通过Git生成本地公钥，并且将公钥添加到GitHub中。&lt;/p>
&lt;p>最后，设置仓库人员的用户名和邮箱地址。&lt;/p>
&lt;p>&lt;strong>具体操作请参考前面的章节&lt;/strong>。当一切都设置完成后，就可以从GitHub上克隆项目到本地了。我们同样以Windows系统为例，打开Git Bash。&lt;/p>
&lt;pre>&lt;code>Company@MININT-IQVJFIT /d/my_test
$ git clone git@github.com:defnngj/project-name.git

Cloning into 'project-name'...
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Checking connectivity... done.

Company@MININT-IQVJFIT /d/my_test
$ cd project-name/

Company@MININT-IQVJFIT /d/my_test/project-name (master)
$ ls

test_case.py
&lt;/code>&lt;/pre>
&lt;p>&lt;strong>“git clone”&lt;/strong> 命令用于克隆GitHub上的项目到本地。通过“cd”命令进入项目目录，查看项目文件。&lt;/p>
&lt;p>另外，我们也可以直接通过http链接克隆项目：&lt;/p>
&lt;pre>&lt;code>$ git clone https://github.com/defnngj/project-name
&lt;/code>&lt;/pre>
&lt;h4 id="更新项目">更新项目&lt;/h4>
&lt;hr>
&lt;p>这次更新我们项目做了较大的变更，创建文件的文件与文件夹，并且删除了原有文件。&lt;/p></description></item></channel></rss>