git basics

[root@localhost ~]# yum  install git
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                         | 3.6 kB  00:00:00     
docker-ce-stable                                             | 3.5 kB  00:00:00     
extras                                                       | 3.4 kB  00:00:00     
updates                                                      | 3.4 kB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 git.x86_64.0.1.8.3.1-20.el7 将被 安装
--> 正在处理依赖关系 perl-Git = 1.8.3.1-20.el7,它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl >= 5.008,它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 rsync,它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(warnings),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(vars),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(strict),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(lib),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(Term::ReadKey),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(Git),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(Getopt::Long),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(File::stat),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(File::Temp),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(File::Spec),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(File::Path),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(File::Find),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(File::Copy),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(File::Basename),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(Exporter),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 perl(Error),它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在处理依赖关系 /usr/bin/perl,它被软件包 git-1.8.3.1-20.el7.x86_64 需要
--> 正在检查事务
---> 软件包 perl.x86_64.4.5.16.3-294.el7_6 将被 安装
--> 正在处理依赖关系 perl-libs = 4:5.16.3-294.el7_6,它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Socket) >= 1.3,它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Scalar::Util) >= 1.10,它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl-macros,它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl-libs,它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(threads::shared),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(threads),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(constant),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Time::Local),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Time::HiRes),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Storable),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Socket),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Scalar::Util),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Pod::Simple::XHTML),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Pod::Simple::Search),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Filter::Util::Call),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 perl(Carp),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
--> 正在处理依赖关系 libperl.so()(64bit),它被软件包 4:perl-5.16.3-294.el7_6.x86_64 需要
---> 软件包 perl-Error.noarch.1.0.17020-2.el7 将被 安装
---> 软件包 perl-Exporter.noarch.0.5.68-3.el7 将被 安装
---> 软件包 perl-File-Path.noarch.0.2.09-2.el7 将被 安装
---> 软件包 perl-File-Temp.noarch.0.0.23.01-3.el7 将被 安装
---> 软件包 perl-Getopt-Long.noarch.0.2.40-3.el7 将被 安装
--> 正在处理依赖关系 perl(Pod::Usage) >= 1.14,它被软件包 perl-Getopt-Long-2.40-3.el7.noarch 需要
--> 正在处理依赖关系 perl(Text::ParseWords),它被软件包 perl-Getopt-Long-2.40-3.el7.noarch 需要
---> 软件包 perl-Git.noarch.0.1.8.3.1-20.el7 将被 安装
---> 软件包 perl-PathTools.x86_64.0.3.40-5.el7 将被 安装
---> 软件包 perl-TermReadKey.x86_64.0.2.30-20.el7 将被 安装
---> 软件包 rsync.x86_64.0.3.1.2-6.el7_6.1 将被 安装
--> 正在检查事务
---> 软件包 perl-Carp.noarch.0.1.26-244.el7 将被 安装
---> 软件包 perl-Filter.x86_64.0.1.49-3.el7 将被 安装
---> 软件包 perl-Pod-Simple.noarch.1.3.28-4.el7 将被 安装
--> 正在处理依赖关系 perl(Pod::Escapes) >= 1.04,它被软件包 1:perl-Pod-Simple-3.28-4.el7.noarch 需要
--> 正在处理依赖关系 perl(Encode),它被软件包 1:perl-Pod-Simple-3.28-4.el7.noarch 需要
---> 软件包 perl-Pod-Usage.noarch.0.1.63-3.el7 将被 安装
--> 正在处理依赖关系 perl(Pod::Text) >= 3.15,它被软件包 perl-Pod-Usage-1.63-3.el7.noarch 需要
--> 正在处理依赖关系 perl-Pod-Perldoc,它被软件包 perl-Pod-Usage-1.63-3.el7.noarch 需要
---> 软件包 perl-Scalar-List-Utils.x86_64.0.1.27-248.el7 将被 安装
---> 软件包 perl-Socket.x86_64.0.2.010-4.el7 将被 安装
---> 软件包 perl-Storable.x86_64.0.2.45-3.el7 将被 安装
---> 软件包 perl-Text-ParseWords.noarch.0.3.29-4.el7 将被 安装
---> 软件包 perl-Time-HiRes.x86_64.4.1.9725-3.el7 将被 安装
---> 软件包 perl-Time-Local.noarch.0.1.2300-2.el7 将被 安装
---> 软件包 perl-constant.noarch.0.1.27-2.el7 将被 安装
---> 软件包 perl-libs.x86_64.4.5.16.3-294.el7_6 将被 安装
---> 软件包 perl-macros.x86_64.4.5.16.3-294.el7_6 将被 安装
---> 软件包 perl-threads.x86_64.0.1.87-4.el7 将被 安装
---> 软件包 perl-threads-shared.x86_64.0.1.43-6.el7 将被 安装
--> 正在检查事务
---> 软件包 perl-Encode.x86_64.0.2.51-7.el7 将被 安装
---> 软件包 perl-Pod-Escapes.noarch.1.1.04-294.el7_6 将被 安装
---> 软件包 perl-Pod-Perldoc.noarch.0.3.20-4.el7 将被 安装
--> 正在处理依赖关系 perl(parent),它被软件包 perl-Pod-Perldoc-3.20-4.el7.noarch 需要
--> 正在处理依赖关系 perl(HTTP::Tiny),它被软件包 perl-Pod-Perldoc-3.20-4.el7.noarch 需要
---> 软件包 perl-podlators.noarch.0.2.5.1-3.el7 将被 安装
--> 正在检查事务
---> 软件包 perl-HTTP-Tiny.noarch.0.0.033-3.el7 将被 安装
---> 软件包 perl-parent.noarch.1.0.225-244.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
====================================================================================
 Package                     架构        版本                    源            大小
====================================================================================
正在安装:
 git                         x86_64      1.8.3.1-20.el7          updates      4.4 M
为依赖而安装:
 perl                        x86_64      4:5.16.3-294.el7_6      updates      8.0 M
 perl-Carp                   noarch      1.26-244.el7            base          19 k
 perl-Encode                 x86_64      2.51-7.el7              base         1.5 M
 perl-Error                  noarch      1:0.17020-2.el7         base          32 k
 perl-Exporter               noarch      5.68-3.el7              base          28 k
 perl-File-Path              noarch      2.09-2.el7              base          26 k
 perl-File-Temp              noarch      0.23.01-3.el7           base          56 k
 perl-Filter                 x86_64      1.49-3.el7              base          76 k
 perl-Getopt-Long            noarch      2.40-3.el7              base          56 k
 perl-Git                    noarch      1.8.3.1-20.el7          updates       55 k
 perl-HTTP-Tiny              noarch      0.033-3.el7             base          38 k
 perl-PathTools              x86_64      3.40-5.el7              base          82 k
 perl-Pod-Escapes            noarch      1:1.04-294.el7_6        updates       51 k
 perl-Pod-Perldoc            noarch      3.20-4.el7              base          87 k
 perl-Pod-Simple             noarch      1:3.28-4.el7            base         216 k
 perl-Pod-Usage              noarch      1.63-3.el7              base          27 k
 perl-Scalar-List-Utils      x86_64      1.27-248.el7            base          36 k
 perl-Socket                 x86_64      2.010-4.el7             base          49 k
 perl-Storable               x86_64      2.45-3.el7              base          77 k
 perl-TermReadKey            x86_64      2.30-20.el7             base          31 k
 perl-Text-ParseWords        noarch      3.29-4.el7              base          14 k
 perl-Time-HiRes             x86_64      4:1.9725-3.el7          base          45 k
 perl-Time-Local             noarch      1.2300-2.el7            base          24 k
 perl-constant               noarch      1.27-2.el7              base          19 k
 perl-libs                   x86_64      4:5.16.3-294.el7_6      updates      688 k
 perl-macros                 x86_64      4:5.16.3-294.el7_6      updates       44 k
 perl-parent                 noarch      1:0.225-244.el7         base          12 k
 perl-podlators              noarch      2.5.1-3.el7             base         112 k
 perl-threads                x86_64      1.87-4.el7              base          49 k
 perl-threads-shared         x86_64      1.43-6.el7              base          39 k
 rsync                       x86_64      3.1.2-6.el7_6.1         updates      404 k
事务概要
====================================================================================
安装  1 软件包 (+31 依赖软件包)
总下载量:16 M
安装大小:59 M
Is this ok [y/d/N]: y
Downloading packages:
(1/32): perl-Carp-1.26-244.el7.noarch.rpm                    |  19 kB  00:00:00     
(2/32): perl-Error-0.17020-2.el7.noarch.rpm                  |  32 kB  00:00:00     
(3/32): perl-Exporter-5.68-3.el7.noarch.rpm                  |  28 kB  00:00:00     
(4/32): perl-File-Path-2.09-2.el7.noarch.rpm                 |  26 kB  00:00:00     
(5/32): perl-Filter-1.49-3.el7.x86_64.rpm                    |  76 kB  00:00:00     
(6/32): perl-File-Temp-0.23.01-3.el7.noarch.rpm              |  56 kB  00:00:00     
(7/32): perl-Getopt-Long-2.40-3.el7.noarch.rpm               |  56 kB  00:00:00     
(8/32): perl-HTTP-Tiny-0.033-3.el7.noarch.rpm                |  38 kB  00:00:00     
(9/32): perl-Git-1.8.3.1-20.el7.noarch.rpm                   |  55 kB  00:00:00     
(10/32): perl-PathTools-3.40-5.el7.x86_64.rpm                |  82 kB  00:00:00     
(11/32): perl-Pod-Escapes-1.04-294.el7_6.noarch.rpm          |  51 kB  00:00:00     
(12/32): perl-Pod-Perldoc-3.20-4.el7.noarch.rpm              |  87 kB  00:00:00     
(13/32): perl-Pod-Usage-1.63-3.el7.noarch.rpm                |  27 kB  00:00:00     
(14/32): perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm      |  36 kB  00:00:00     
(15/32): perl-Pod-Simple-3.28-4.el7.noarch.rpm               | 216 kB  00:00:00     
(16/32): perl-Socket-2.010-4.el7.x86_64.rpm                  |  49 kB  00:00:00     
(17/32): perl-Storable-2.45-3.el7.x86_64.rpm                 |  77 kB  00:00:00     
(18/32): perl-Text-ParseWords-3.29-4.el7.noarch.rpm          |  14 kB  00:00:00     
(19/32): perl-TermReadKey-2.30-20.el7.x86_64.rpm             |  31 kB  00:00:00     
(20/32): perl-Time-HiRes-1.9725-3.el7.x86_64.rpm             |  45 kB  00:00:00     
(21/32): perl-Time-Local-1.2300-2.el7.noarch.rpm             |  24 kB  00:00:00     
(22/32): perl-constant-1.27-2.el7.noarch.rpm                 |  19 kB  00:00:00     
(23/32): perl-macros-5.16.3-294.el7_6.x86_64.rpm             |  44 kB  00:00:00     
(24/32): perl-parent-0.225-244.el7.noarch.rpm                |  12 kB  00:00:00     
(25/32): perl-podlators-2.5.1-3.el7.noarch.rpm               | 112 kB  00:00:00     
(26/32): perl-threads-1.87-4.el7.x86_64.rpm                  |  49 kB  00:00:00     
(27/32): perl-threads-shared-1.43-6.el7.x86_64.rpm           |  39 kB  00:00:00     
(28/32): perl-libs-5.16.3-294.el7_6.x86_64.rpm               | 688 kB  00:00:01     
(29/32): rsync-3.1.2-6.el7_6.1.x86_64.rpm                    | 404 kB  00:00:01     
(30/32): perl-5.16.3-294.el7_6.x86_64.rpm                    | 8.0 MB  00:00:08     
(31/32): git-1.8.3.1-20.el7.x86_64.rpm                       | 4.4 MB  00:00:09     
(32/32): perl-Encode-2.51-7.el7.x86_64.rpm                   | 1.5 MB  00:00:13     
------------------------------------------------------------------------------------
总计                                                   1.2 MB/s |  16 MB  00:13     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 1:perl-parent-0.225-244.el7.noarch                             1/32 
  正在安装    : perl-HTTP-Tiny-0.033-3.el7.noarch                              2/32 
  正在安装    : perl-podlators-2.5.1-3.el7.noarch                              3/32 
  正在安装    : perl-Pod-Perldoc-3.20-4.el7.noarch                             4/32 
  正在安装    : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch                       5/32 
  正在安装    : perl-Encode-2.51-7.el7.x86_64                                  6/32 
  正在安装    : perl-Text-ParseWords-3.29-4.el7.noarch                         7/32 
  正在安装    : perl-Pod-Usage-1.63-3.el7.noarch                               8/32 
  正在安装    : 4:perl-libs-5.16.3-294.el7_6.x86_64                            9/32 
  正在安装    : 4:perl-macros-5.16.3-294.el7_6.x86_64                         10/32 
  正在安装    : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                         11/32 
  正在安装    : perl-Exporter-5.68-3.el7.noarch                               12/32 
  正在安装    : perl-constant-1.27-2.el7.noarch                               13/32 
  正在安装    : perl-Time-Local-1.2300-2.el7.noarch                           14/32 
  正在安装    : perl-Socket-2.010-4.el7.x86_64                                15/32 
  正在安装    : perl-Carp-1.26-244.el7.noarch                                 16/32 
  正在安装    : perl-Storable-2.45-3.el7.x86_64                               17/32 
  正在安装    : perl-PathTools-3.40-5.el7.x86_64                              18/32 
  正在安装    : perl-Scalar-List-Utils-1.27-248.el7.x86_64                    19/32 
  正在安装    : perl-File-Temp-0.23.01-3.el7.noarch                           20/32 
  正在安装    : perl-File-Path-2.09-2.el7.noarch                              21/32 
  正在安装    : perl-threads-shared-1.43-6.el7.x86_64                         22/32 
  正在安装    : perl-threads-1.87-4.el7.x86_64                                23/32 
  正在安装    : 1:perl-Pod-Simple-3.28-4.el7.noarch                           24/32 
  正在安装    : perl-Filter-1.49-3.el7.x86_64                                 25/32 
  正在安装    : perl-Getopt-Long-2.40-3.el7.noarch                            26/32 
  正在安装    : 4:perl-5.16.3-294.el7_6.x86_64                                27/32 
  正在安装    : 1:perl-Error-0.17020-2.el7.noarch                             28/32 
  正在安装    : perl-TermReadKey-2.30-20.el7.x86_64                           29/32 
  正在安装    : rsync-3.1.2-6.el7_6.1.x86_64                                  30/32 
  正在安装    : perl-Git-1.8.3.1-20.el7.noarch                                31/32 
  正在安装    : git-1.8.3.1-20.el7.x86_64                                     32/32 
  验证中      : perl-HTTP-Tiny-0.033-3.el7.noarch                              1/32 
  验证中      : perl-threads-shared-1.43-6.el7.x86_64                          2/32 
  验证中      : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                          3/32 
  验证中      : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch                       4/32 
  验证中      : perl-Exporter-5.68-3.el7.noarch                                5/32 
  验证中      : perl-constant-1.27-2.el7.noarch                                6/32 
  验证中      : perl-PathTools-3.40-5.el7.x86_64                               7/32 
  验证中      : rsync-3.1.2-6.el7_6.1.x86_64                                   8/32 
  验证中      : 1:perl-parent-0.225-244.el7.noarch                             9/32 
  验证中      : perl-TermReadKey-2.30-20.el7.x86_64                           10/32 
  验证中      : 4:perl-libs-5.16.3-294.el7_6.x86_64                           11/32 
  验证中      : perl-File-Temp-0.23.01-3.el7.noarch                           12/32 
  验证中      : perl-Git-1.8.3.1-20.el7.noarch                                13/32 
  验证中      : perl-Time-Local-1.2300-2.el7.noarch                           14/32 
  验证中      : 4:perl-macros-5.16.3-294.el7_6.x86_64                         15/32 
  验证中      : perl-Socket-2.010-4.el7.x86_64                                16/32 
  验证中      : perl-Carp-1.26-244.el7.noarch                                 17/32 
  验证中      : 1:perl-Error-0.17020-2.el7.noarch                             18/32 
  验证中      : git-1.8.3.1-20.el7.x86_64                                     19/32 
  验证中      : perl-Storable-2.45-3.el7.x86_64                               20/32 
  验证中      : perl-Scalar-List-Utils-1.27-248.el7.x86_64                    21/32 
  验证中      : perl-Pod-Usage-1.63-3.el7.noarch                              22/32 
  验证中      : perl-Encode-2.51-7.el7.x86_64                                 23/32 
  验证中      : perl-Pod-Perldoc-3.20-4.el7.noarch                            24/32 
  验证中      : perl-podlators-2.5.1-3.el7.noarch                             25/32 
  验证中      : perl-File-Path-2.09-2.el7.noarch                              26/32 
  验证中      : perl-threads-1.87-4.el7.x86_64                                27/32 
  验证中      : 1:perl-Pod-Simple-3.28-4.el7.noarch                           28/32 
  验证中      : perl-Filter-1.49-3.el7.x86_64                                 29/32 
  验证中      : perl-Getopt-Long-2.40-3.el7.noarch                            30/32 
  验证中      : perl-Text-ParseWords-3.29-4.el7.noarch                        31/32 
  验证中      : 4:perl-5.16.3-294.el7_6.x86_64                                32/32 
已安装:
  git.x86_64 0:1.8.3.1-20.el7                                                       
作为依赖被安装:
  perl.x86_64 4:5.16.3-294.el7_6                                                    
  perl-Carp.noarch 0:1.26-244.el7                                                   
  perl-Encode.x86_64 0:2.51-7.el7                                                   
  perl-Error.noarch 1:0.17020-2.el7                                                 
  perl-Exporter.noarch 0:5.68-3.el7                                                 
  perl-File-Path.noarch 0:2.09-2.el7                                                
  perl-File-Temp.noarch 0:0.23.01-3.el7                                             
  perl-Filter.x86_64 0:1.49-3.el7                                                   
  perl-Getopt-Long.noarch 0:2.40-3.el7                                              
  perl-Git.noarch 0:1.8.3.1-20.el7                                                  
  perl-HTTP-Tiny.noarch 0:0.033-3.el7                                               
  perl-PathTools.x86_64 0:3.40-5.el7                                                
  perl-Pod-Escapes.noarch 1:1.04-294.el7_6                                          
  perl-Pod-Perldoc.noarch 0:3.20-4.el7                                              
  perl-Pod-Simple.noarch 1:3.28-4.el7                                               
  perl-Pod-Usage.noarch 0:1.63-3.el7                                                
  perl-Scalar-List-Utils.x86_64 0:1.27-248.el7                                      
  perl-Socket.x86_64 0:2.010-4.el7                                                  
  perl-Storable.x86_64 0:2.45-3.el7                                                 
  perl-TermReadKey.x86_64 0:2.30-20.el7                                             
  perl-Text-ParseWords.noarch 0:3.29-4.el7                                          
  perl-Time-HiRes.x86_64 4:1.9725-3.el7                                             
  perl-Time-Local.noarch 0:1.2300-2.el7                                             
  perl-constant.noarch 0:1.27-2.el7                                                 
  perl-libs.x86_64 4:5.16.3-294.el7_6                                               
  perl-macros.x86_64 4:5.16.3-294.el7_6                                             
  perl-parent.noarch 1:0.225-244.el7                                                
  perl-podlators.noarch 0:2.5.1-3.el7                                               
  perl-threads.x86_64 0:1.87-4.el7                                                  
  perl-threads-shared.x86_64 0:1.43-6.el7                                           
  rsync.x86_64 0:3.1.2-6.el7_6.1                                                    
完毕!
[root@localhost ~]# git
usage: git [--version] [--help] [-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>]
最常用的 git 命令有:
   add        添加文件内容至索引
   bisect     通过二分查找定位引入 bug 的变更
   branch     列出、创建或删除分支
   checkout   检出一个分支或路径到工作区
   clone      克隆一个版本库到一个新目录
   commit     记录变更到版本库
   diff       显示提交之间、提交和工作区之间等的差异
   fetch      从另外一个版本库下载对象和引用
   grep       输出和模式匹配的行
   init       创建一个空的 Git 版本库或重新初始化一个已存在的版本库
   log        显示提交日志
   merge      合并两个或更多开发历史
   mv         移动或重命名一个文件、目录或符号链接
   pull       获取并合并另外的版本库或一个本地分支
   push       更新远程引用和相关的对象
   rebase     本地提交转移至更新后的上游分支中
   reset      重置当前HEAD到指定状态
   rm         从工作区和索引中删除文件
   show       显示各种类型的对象
   status     显示工作区状态
   tag        创建、列出、删除或校验一个GPG签名的 tag 对象
命令 'git help -a' 和 'git help -g' 显示可用的子命令和一些指南。参见
'git help <命令>' 或 'git help <指南>' 来查看给定的子命令帮助或指南。
[root@localhost ~]# git -v
Unknown option: -v
usage: git [--version] [--help] [-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>]
[root@localhost ~]# git
usage: git [--version] [--help] [-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>]
最常用的 git 命令有:
   add        添加文件内容至索引
   bisect     通过二分查找定位引入 bug 的变更
   branch     列出、创建或删除分支
   checkout   检出一个分支或路径到工作区
   clone      克隆一个版本库到一个新目录
   commit     记录变更到版本库
   diff       显示提交之间、提交和工作区之间等的差异
   fetch      从另外一个版本库下载对象和引用
   grep       输出和模式匹配的行
   init       创建一个空的 Git 版本库或重新初始化一个已存在的版本库
   log        显示提交日志
   merge      合并两个或更多开发历史
   mv         移动或重命名一个文件、目录或符号链接
   pull       获取并合并另外的版本库或一个本地分支
   push       更新远程引用和相关的对象
   rebase     本地提交转移至更新后的上游分支中
   reset      重置当前HEAD到指定状态
   rm         从工作区和索引中删除文件
   show       显示各种类型的对象
   status     显示工作区状态
   tag        创建、列出、删除或校验一个GPG签名的 tag 对象
命令 'git help -a' 和 'git help -g' 显示可用的子命令和一些指南。参见
'git help <命令>' 或 'git help <指南>' 来查看给定的子命令帮助或指南。
[root@localhost ~]# mkdir learngit
[root@localhost ~]# cd learngit/
[root@localhost learngit]# pwd
/root/learngit
[root@localhost learngit]# git init
初始化空的 Git 版本库于 /root/learngit/.git/
[root@localhost learngit]# ls -al
总用量 0
drwxr-xr-x. 3 root root  18 5月  12 16:51 .
dr-xr-x---. 6 root root 196 5月  12 16:51 ..
drwxr-xr-x. 7 root root 119 5月  12 16:51 .git
[root@localhost learngit]# touch readme.txt
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# git add readme.txt 
[root@localhost learngit]# git commit -m "wrote a readme file"
[master(根提交) 66bfe12] wrote a readme file
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 1 file changed, 2 insertions(+)
 create mode 100644 readme.txt
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# git status
# 位于分支 master
# 尚未暂存以备提交的变更:
#   (使用 "git add <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#    修改:      readme.txt
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@localhost learngit]# git diff readme.txt 
diff --git a/readme.txt b/readme.txt
index 46d49bf..9247db6 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,2 @@
-Git is a version control system.
+Git is a distributed version control system.
 Git is free software.
[root@localhost learngit]# git  add readme.txt 
[root@localhost learngit]# git  status
# 位于分支 master
# 要提交的变更:
#   (使用 "git reset HEAD <file>..." 撤出暂存区)
#
#    修改:      readme.txt
#
[root@localhost learngit]# git commit -m "add distributed"
[master 622c122] add distributed
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+), 1 deletion(-)
[root@localhost learngit]# git status
# 位于分支 master
无文件要提交,干净的工作区
[root@localhost learngit]# ls
readme.txt
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# git add readme.txt 
[root@localhost learngit]# git commit -m "append GPL"
[master a40ad57] append GPL
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+), 1 deletion(-)
[root@localhost learngit]# GIT LOG
-bash: GIT: 未找到命令
[root@localhost learngit]# git log
commit a40ad578b4393eae9e1e2c9f076b118434f3c0ce
Author: root <root@localhost.localdomain>
Date:   Sun May 12 17:00:41 2019 +0800

    append GPL

commit 622c12265f358579f1fadca9329f4d2b498679a7
Author: root <root@localhost.localdomain>
Date:   Sun May 12 16:58:59 2019 +0800

    add distributed

commit 66bfe1280768abab4bd34e38ae5646a24c626540
Author: root <root@localhost.localdomain>
Date:   Sun May 12 16:54:29 2019 +0800

    wrote a readme file
[root@localhost learngit]# git log --pretty=oneline
a40ad578b4393eae9e1e2c9f076b118434f3c0ce append GPL
622c12265f358579f1fadca9329f4d2b498679a7 add distributed
66bfe1280768abab4bd34e38ae5646a24c626540 wrote a readme file
[root@localhost learngit]# 

 

[root@localhost ~]# ls
anaconda-ks.cfg  learngit  static_web
[root@localhost ~]# cd learngit/
[root@localhost learngit]# ls
readme.txt
[root@localhost learngit]# git log
commit a40ad578b4393eae9e1e2c9f076b118434f3c0ce
Author: root <root@localhost.localdomain>
Date:   Sun May 12 17:00:41 2019 +0800

    append GPL

commit 622c12265f358579f1fadca9329f4d2b498679a7
Author: root <root@localhost.localdomain>
Date:   Sun May 12 16:58:59 2019 +0800

    add distributed

commit 66bfe1280768abab4bd34e38ae5646a24c626540
Author: root <root@localhost.localdomain>
Date:   Sun May 12 16:54:29 2019 +0800

    wrote a readme file
    wrote a readme file
[root@localhost learngit]# git reset --hard HEAD^
HEAD 现在位于 622c122 add distributed
[root@localhost learngit]# 
[root@localhost learngit]# ls
readme.txt
[root@localhost learngit]# cat readme.txt 
Git is a distributed version control system.
Git is free software.
[root@localhost learngit]# git log
commit 622c12265f358579f1fadca9329f4d2b498679a7
Author: root <root@localhost.localdomain>
Date:   Sun May 12 16:58:59 2019 +0800

    add distributed

commit 66bfe1280768abab4bd34e38ae5646a24c626540
Author: root <root@localhost.localdomain>
Date:   Sun May 12 16:54:29 2019 +0800

    wrote a readme file
[root@localhost learngit]# git reset --hard a40ad57
HEAD 现在位于 a40ad57 append GPL
[root@localhost learngit]# ls
readme.txt
[root@localhost learngit]# cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
[root@localhost learngit]# git reflog
a40ad57 HEAD@{0}: reset: moving to a40ad57
622c122 HEAD@{1}: reset: moving to HEAD^
a40ad57 HEAD@{2}: commit: append GPL
622c122 HEAD@{3}: commit: add distributed
66bfe12 HEAD@{4}: commit (initial): wrote a readme file
[root@localhost learngit]# ls
readme.txt
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# ls
readme.txt
[root@localhost learngit]# touch LICENSE
[root@localhost learngit]# git status
# 位于分支 master
# 尚未暂存以备提交的变更:
#   (使用 "git add <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#    修改:      readme.txt
#
# 未跟踪的文件:
#   (使用 "git add <file>..." 以包含要提交的内容)
#
#    LICENSE
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@localhost learngit]# git add readme.txt LICENSE 
[root@localhost learngit]# git status
# 位于分支 master
# 要提交的变更:
#   (使用 "git reset HEAD <file>..." 撤出暂存区)
#
#    新文件:    LICENSE
#    修改:      readme.txt
#
[root@localhost learngit]# git commit -m "understand how stage works"
[master 3b2caab] understand how stage works
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 2 files changed, 1 insertion(+)
 create mode 100644 LICENSE
[root@localhost learngit]# git status
# 位于分支 master
无文件要提交,干净的工作区
[root@localhost learngit]# vim readme.txt 
-bash: vim: 未找到命令
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# git add readme.txt 
[root@localhost learngit]# git status
# 位于分支 master
# 要提交的变更:
#   (使用 "git reset HEAD <file>..." 撤出暂存区)
#
#    修改:      readme.txt
#
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# git commit -m "git tracks changes"
[master 02dc942] git tracks changes
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
[root@localhost learngit]# git status
# 位于分支 master
# 尚未暂存以备提交的变更:
#   (使用 "git add <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#    修改:      readme.txt
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@localhost learngit]# git diff HEAD -- readme.txt 
diff --git a/readme.txt b/readme.txt
index 76d770f..a9c5755 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,4 +1,4 @@
 Git is a distributed version control
 Git is free software distributed und
 Git has a mutable index called stage
-Git tracks changes.
+Git tracks changes of files.
(END)...skipping...
diff --git a/readme.txt b/readme.txt
index 76d770f..a9c5755 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,4 +1,4 @@
 Git is a distributed version control system.
 Git is free software distributed under the GPL.
 Git has a mutable index called stage.
-Git tracks changes.
+Git tracks changes of files.
~
~
~
~
~
~
~
~
~
[root@localhost learngit]# 
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# git status
# 位于分支 master
# 尚未暂存以备提交的变更:
#   (使用 "git add <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#    修改:      readme.txt
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@localhost learngit]# git checkout -- readme.txt 
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# git add readme.txt 
[root@localhost learngit]# git status
# 位于分支 master
# 要提交的变更:
#   (使用 "git reset HEAD <file>..." 撤出暂存区)
#
#    修改:      readme.txt
#
[root@localhost learngit]# git reset HEAD readme.txt 
重置后撤出暂存区的变更:
M    readme.txt
[root@localhost learngit]# cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
My stupid boss still prefers SVN.
[root@localhost learngit]# git status
# 位于分支 master
# 尚未暂存以备提交的变更:
#   (使用 "git add <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#    修改:      readme.txt
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@localhost learngit]# git checkout -- readme.txt 
[root@localhost learngit]# git status
# 位于分支 master
无文件要提交,干净的工作区
[root@localhost learngit]# cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# touch test.txt
[root@localhost learngit]# git add test.txt 
[root@localhost learngit]# git status
# 位于分支 master
# 要提交的变更:
#   (使用 "git reset HEAD <file>..." 撤出暂存区)
#
#    新文件:    test.txt
#
[root@localhost learngit]# ls
LICENSE  readme.txt  test.txt
[root@localhost learngit]# cat test.txt 
[root@localhost learngit]# git commit -m "add test.txt"
[master 62bbb1e] add test.txt
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test.txt
[root@localhost learngit]# git stastus
git:'stastus' 不是一个 git 命令。参见 'git --help'。

您指的是这个么?
    status
[root@localhost learngit]# git status
# 位于分支 master
无文件要提交,干净的工作区
[root@localhost learngit]# ls
LICENSE  readme.txt  test.txt
[root@localhost learngit]# rm test.txt 
rm:是否删除普通空文件 "test.txt"?y
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# git status
# 位于分支 master
# 尚未暂存以备提交的变更:
#   (使用 "git add/rm <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#    删除:      test.txt
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@localhost learngit]# git rm test.txt
rm 'test.txt'
[root@localhost learngit]# git status
# 位于分支 master
# 要提交的变更:
#   (使用 "git reset HEAD <file>..." 撤出暂存区)
#
#    删除:      test.txt
#
[root@localhost learngit]# git commit -m "remove test.txt"
[master ccd4596] remove test.txt
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 test.txt
[root@localhost learngit]# git status
# 位于分支 master
无文件要提交,干净的工作区
[root@localhost learngit]# cd
[root@localhost ~]# ls
anaconda-ks.cfg  static_web
learngit
[root@localhost ~]# ls -al
总用量 28
dr-xr-x---.  6 root root  196 5月  12 16:51 .
dr-xr-xr-x. 17 root root  224 5月  11 23:08 ..
-rw-------.  1 root root 1257 5月  11 23:09 anaconda-ks.cfg
-rw-------.  1 root root 1687 5月  12 18:47 .bash_history
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
drwx------.  2 root root   25 5月  12 15:54 .docker
drwxr-xr-x.  3 root root   51 5月  12 19:21 learngit
drwxr-----.  3 root root   19 5月  11 15:23 .pki
drwxr-xr-x.  2 root root   24 5月  12 16:24 static_web
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
[root@localhost ~]# ls -al
总用量 28
dr-xr-x---.  6 root root  196 5月  12 16:51 .
dr-xr-xr-x. 17 root root  224 5月  11 23:08 ..
-rw-------.  1 root root 1257 5月  11 23:09 anaconda-ks.cfg
-rw-------.  1 root root 1687 5月  12 18:47 .bash_history
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
drwx------.  2 root root   25 5月  12 15:54 .docker
drwxr-xr-x.  3 root root   51 5月  12 19:21 learngit
drwxr-----.  3 root root   19 5月  11 15:23 .pki
drwxr-xr-x.  2 root root   24 5月  12 16:24 static_web
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
[root@localhost ~]# ssh-keygen -t rsa -C "1@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:
The key's randomart image is:
+---[RSA 2048]----+
-+
[root@localhost ~]# ls 
anaconda-ks.cfg  learngit  static_web
[root@localhost ~]# ls -al
总用量 28
dr-xr-x---.  7 root root  208 5月  12 19:27 .
dr-xr-xr-x. 17 root root  224 5月  11 23:08 ..
-rw-------.  1 root root 1257 5月  11 23:09 anaconda-ks.cfg
-rw-------.  1 root root 1687 5月  12 18:47 .bash_history
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
drwx------.  2 root root   25 5月  12 15:54 .docker
drwxr-xr-x.  3 root root   51 5月  12 19:21 learngit
drwxr-----.  3 root root   19 5月  11 15:23 .pki
drwx------.  2 root root   38 5月  12 19:27 .ssh
drwxr-xr-x.  2 root root   24 5月  12 16:24 static_web
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
[root@localhost ~]# cd .ssh/
[root@localhost .ssh]# ls
id_rsa  id_rsa.pub
[root@localhost .ssh]# cat id_rsa.pub 
ssh-rsa 
[root@localhost .ssh]# git remote add origin git@github.com
fatal: Not a git repository (or any of the parent directories): .git
[root@localhost .ssh]# cd 
[root@localhost ~]# ls
anaconda-ks.cfg  learngit  static_web
[root@localhost ~]# cd learngit/
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# git remote add origin git@github.com
[root@localhost learngit]# git push -u origin master
Counting objects: 19, done.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (19/19), 1.56 KiB | 0 bytes/s, done.
Total 19 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), done.
To git@github.com
 * [new branch]      master -> master
分支 master 设置为跟踪来自 origin 的远程分支 master。

[root@localhost ~]# ls
anaconda-ks.cfg  learngit  rancher  static_web
[root@localhost ~]# cd learngit/
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# git check -b dev
git:'check' 不是一个 git 命令。参见 'git --help'。
您指的是这其中的某一个么?
    checkout
    check-attr
    cherry
[root@localhost learngit]# git checkout -b dev
切换到一个新分支 'dev'
[root@localhost learngit]# git branch
* dev
  master
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# git add readme.txt 
[root@localhost learngit]# git commit -m "branch test"
[dev a493a42] branch test
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
[root@localhost learngit]# git status
# 位于分支 dev
无文件要提交,干净的工作区
[root@localhost learngit]# git checkout master
切换到分支 'master'
[root@localhost learngit]# git status
# 位于分支 master
无文件要提交,干净的工作区
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
[root@localhost learngit]# git merge dev
更新 ccd4596..a493a42
Fast-forward
 readme.txt | 1 +
 1 file changed, 1 insertion(+)
[root@localhost learngit]# cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
Creating a new branch is quick.
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
Creating a new branch is quick.
[root@localhost learngit]# git branch -d dev
已删除分支 dev(曾为 a493a42)。
[root@localhost learngit]# git branch
* master
[root@localhost learngit]# git checkout -b feature1
切换到一个新分支 'feature1'
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# git status
# 位于分支 feature1
# 尚未暂存以备提交的变更:
#   (使用 "git add <file>..." 更新要提交的内容)
#   (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
#    修改:      readme.txt
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@localhost learngit]# git add readme.txt 
[root@localhost learngit]# git commit -m "AND Simple"
[feature1 9d80572] AND Simple
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
[root@localhost learngit]# git checkout master
切换到分支 'master'
您的分支领先 'origin/master' 共 1 个提交。
  (使用 "git push" 来发布您的本地提交)
[root@localhost learngit]# cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
Creating a new branch is quick.
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# git add readme.txt 
[root@localhost learngit]# git commit -m "& simple"
[master f9683b0] & simple
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
[root@localhost learngit]# git merge feature1
自动合并 readme.txt
冲突(内容):合并冲突于 readme.txt
自动合并失败,修正冲突然后提交修正的结果。
[root@localhost learngit]# git status
# 位于分支 master
# 您的分支领先 'origin/master' 共 2 个提交。
#   (使用 "git push" 来发布您的本地提交)
#
# 您有尚未合并的路径。
#   (解决冲突并运行 "git commit")
#
# 未合并的路径:
#   (使用 "git add <file>..." 标记解决方案)
#
#    双方修改:     readme.txt
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@localhost learngit]# ls
LICENSE  readme.txt
[root@localhost learngit]# cat readme.txt 
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
Creating a new branch is quick.
<<<<<<< HEAD
Creating a new branch is quick & simple.
=======
Creating a new branch is quick AND simple.
>>>>>>> feature1
[root@localhost learngit]# vi readme.txt 
>>>>>>> feature1
[root@localhost learngit]# vi readme.txt 
[root@localhost learngit]# git add readme.txt 
[root@localhost learngit]# git commit -m "conflict fixed"
[master e5a5b93] conflict fixed
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

[root@localhost learngit]# git log
commit e5a5b930d20df9eea73ab5892fd74aff53dff8a1
Merge: f9683b0 9d80572
Author: root <root@localhost.localdomain>
Date:   Sun May 12 20:08:14 2019 +0800

    conflict fixed

commit f9683b06df75942891380155e482c4af1f2664f3
Author: root <root@localhost.localdomain>
Date:   Sun May 12 20:02:08 2019 +0800

    & simple

commit 9d8057277e05a43ce94f2ffb6b234cf63bb6d9a2
Author: root <root@localhost.localdomain>
Date:   Sun May 12 20:00:03 2019 +0800

    AND Simple

[root@localhost learngit]# git log --graph --pretty=oneline --abbrev-commit
*   e5a5b93 conflict fixed
|\  
| * 9d80572 AND Simple
* | f9683b0 & simple
|/  
* a493a42 branch test
* ccd4596 remove test.txt
* 62bbb1e add test.txt
* 02dc942 git tracks changes
* 3b2caab understand how stage works
* a40ad57 append GPL
* 622c122 add distributed
* 66bfe12 wrote a readme file
[root@localhost learngit]# git branch -d feature1
已删除分支 feature1(曾为 9d80572)。

转载于:https://my.oschina.net/donngchao/blog/3048625

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值