且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Git学习系列之Windows上安装Git详细步骤(图文详解)

更新时间:2022-04-06 05:50:32

前言

  最初,Git是用于Linux下的内核代码管理。因为其非常好用,目前,已经被成功移植到Mac和Windows操作系统下。

  鉴于大部分使用者使用的是Windows操作系统,故,这里详细讲解Windows操作系统下Git的安装步骤。

       当然我也会陆续写出Linux和Mac操作系统下Git的安装步骤。

 

 

 

 

安装前的说明

    Git在windows平台上安装说明。

         Git 是 Linux Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。目前Git已经可以在windows下使用,主要方法有二:msysgit和Cygwin。Cygwin和Linux使用方法类似,Windows版本的Git提供了友好的GUI(图形界面),安装后很快可以上手,此处我们主要讨论基于msysgit的Git安装和使用。

         TortoiseGit是TortoiseSVN的Git版本,TortoiseGit用于迁移TortoiseSVN到TortoiseGit。一直以来Git在Windows平台没有好用GUI客户端,现在TortoiseGit的出现给Windows开发者带来福音。我们将在64位win7操作系统上安装Git,并使用GUI界面,则需同时安装msysGit和TortoiseGit。

 

 

 

安装步骤

  1. 安装包下载

  安装包的下载,常用的有两种方式

  (1). 百度直接搜索关键词“Git”,在弹出的结果中,通过百度软件中心下载,截图如下所示。这种方法有一个缺点,就是安装包不是最新的。如果图省事的话,可以采取这种方法。

  (2). 官网下载。网址为:https://git-scm.com/download。截图如下所示。点击“Downloads for Windows”按钮,便可跳转到下载链接,完成下载。

Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 

 

 

 

  2. Git安装

  这里,我以Git 2.8.1 版本安装包为例,进行安装步骤讲解。(因为这一版本是目前公司里用的最多的稳定版本)

  1. 双击安装包。截图如下所示。

Git学习系列之Windows上安装Git详细步骤(图文详解)

  点击下一步。

 Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 

  3、配置安装组件

  默认即可,点击“Next。默认已经都帮我们否选上了。包括创建桌面快捷方式、Git Bash、Git GUi、已经目录和后缀关联等。

 Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 

  可勾选:On the Desktop,这样,会自动在桌面生成Git的快捷方式。

  可不勾选:Git GUI Here。目前,我都是使用Git Bash来进行操作。使用Git GUI,确实可以得到更好的UI体验,不过,个人认为会减低效率。并且,初学者,还是先搞懂Git的常用指令,之后,再使用Git GUI才会有更好的理解。

Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 

 

   在“Adjusting your PATH environment”选项中,默认即可。点击“Next”。
这个步骤***选择第二项“Use Git from the Windows Command Prompt”, 这样在Windows的命令行cmd中也可以运行git命令了。这样会对以后的一些操作带来方便。

 Git学习系列之Windows上安装Git详细步骤(图文详解)

 Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 

 

 

  配置行结束标记,保持默认“Checkout Windows-style, commit Unix-style line endings”。

 Git学习系列之Windows上安装Git详细步骤(图文详解)

 Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 

 

 

 

 

在终端模拟器选择页面,默认即可,配置后Git Gash的终端比较易用。然后点击“Next”。

 Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 

 

 

 

 

 

最后配置Git额外选择默认即可。然后点击“Install”开始安装。如果之前安装过旧版本,会先卸载然后再安装新版本。

 Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 

 

 

安装完成,默认点"Finish"即可。这样会在浏览器打开新版本的信息。

 Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 

 

 

 

  安装Git完成之后,会在桌面创建Git Bash快捷方式,在任意目录下右击鼠标可以找打Git Bash Here的选项。打开Git客户端界面,输入git。

 Git学习系列之Windows上安装Git详细步骤(图文详解)

Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 

Git学习系列之Windows上安装Git详细步骤(图文详解)

 

 

 

 Git学习系列之Windows上安装Git详细步骤(图文详解)

Git学习系列之Windows上安装Git详细步骤(图文详解)
lenovo@LAPTOP-LG72BB3R MINGW64 /
$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

lenovo@LAPTOP-LG72BB3R MINGW64 /
$ pwd
/

lenovo@LAPTOP-LG72BB3R MINGW64 /
$ ls
bin/  cmd/  dev/  etc/  git-bash.exe*  git-cmd.exe*  LICENSE.txt  mingw64/  proc/  ReleaseNotes.html  tmp/  unins000.dat  unins000.exe*  unins000.msg  usr/

lenovo@LAPTOP-LG72BB3R MINGW64 /
$
Git学习系列之Windows上安装Git详细步骤(图文详解)

  我们可以开始学习Git了。

 

 

 

   如果按照前面的步骤安装下来,那么 git 程序所在的路径已经添加到系统 PATH 中(path就相当于系统自动查找路径列表),所以可以直接在任意路径的 cmd 下执行 git 命令。 如果没有添加,则需要 cd 切换到Git所在的 bin 目录下,才能执行 git 命令。


本文转自大数据躺过的坑博客园博客,原文链接:http://www.cnblogs.com/zlslch/p/7985285.html,如需转载请自行联系原作者