美文网首页
1.2 查看Git命令的帮助信息

1.2 查看Git命令的帮助信息

作者: 黄刚刚 | 来源:发表于2019-06-04 11:15 被阅读0次

    1.在命令行键入git会显示帮助信息,帮助信息很详细

    [root@localhost git]# 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 <指南>' 来查看给定的子命令帮助或指南。

    2.查看git 可用的子命令

    [root@localhost git]# git help -a

    用法: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>]

    在 '/usr/libexec/git-core' 下可用的 git 命令

      add                      merge-resolve

      add--interactive          merge-subtree

      am                        merge-tree

      annotate                  mergetool

      apply                    mktag

      archive                  mktree

      bisect                    mv

      bisect--helper            name-rev

      blame                    notes

      branch                    pack-objects

      bundle                    pack-redundant

      cat-file                  pack-refs

      check-attr                patch-id

      check-ignore              peek-remote

      check-ref-format          prune

      checkout                  prune-packed

      checkout-index            pull

      cherry                    push

      cherry-pick              quiltimport

      clean                    read-tree

      clone                    rebase

      column                    receive-pack

      commit                    reflog

      commit-tree              relink

      config                    remote

      count-objects            remote-ext

      credential                remote-fd

      credential-cache          remote-ftp

      credential-cache--daemon  remote-ftps

      credential-store          remote-http

      describe                  remote-https

      diff                      remote-testpy

      diff-files                repack

      diff-index                replace

      diff-tree                repo-config

      difftool                  request-pull

      difftool--helper          rerere

      fast-export              reset

      fast-import              rev-list

      fetch                    rev-parse

      fetch-pack                revert

      filter-branch            rm

      fmt-merge-msg            send-pack

      for-each-ref              sh-i18n--envsubst

      format-patch              shell

      fsck                      shortlog

      fsck-objects              show

      gc                        show-branch

      get-tar-commit-id        show-index

      grep                      show-ref

      hash-object              stage

      help                      stash

      http-backend              status

      http-fetch                stripspace

      http-push                submodule

      imap-send                submodule--helper

      index-pack                subtree

      init                      symbolic-ref

      init-db                  tag

      log                      tar-tree

      lost-found                unpack-file

      ls-files                  unpack-objects

      ls-remote                update-index

      ls-tree                  update-ref

      mailinfo                  update-server-info

      mailsplit                upload-archive

      merge                    upload-pack

      merge-base                var

      merge-file                verify-pack

      merge-index              verify-tag

      merge-octopus            web--browse

      merge-one-file            whatchanged

      merge-ours                write-tree

      merge-recursive

    命令 'git help -a' 和 'git help -g' 显示可用的子命令和一些指南。参见

    'git help <命令>' 或 'git help <指南>' 来查看给定的子命令帮助或指南。

    3.使用git help <命令>查看命令的帮助信息

    [root@localhost bbs]# git help clone

    NAME

          git-clone - Clone a repository into a new directory

    SYNOPSIS

          git clone [--template=<template_directory>]

                    [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]

                    [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]

                    [--separate-git-dir <git dir>]

                    [--depth <depth>] [--[no-]single-branch]

                    [--recursive | --recurse-submodules] [--] <repository>

                    [<directory>]

    注:从帮助信息的SYNOPSIS字段可以看出clone命令的使用方式和支持的命令选项,

    具体每个命令选项的含义需要查看"帮助信息"的OPTIONS字段对应选项的描述,

    "[]"的是可选命令选项,"<>"是必传参数,

    由此可以看出,<repository>是必传参数,紧随其后的[<directory>]是一个可选参数,那就看看对应选项的描述:

    <repository>

              The (possibly remote) repository to clone from. See the URLS section below for more information on

              specifying repositories.

    <directory>

              The name of a new directory to clone into. The "humanish" part of the source repository is used if no

              directory is explicitly given (repo for /path/to/repo.git and foo for host.xz:foo/.git). Cloning into an

              existing directory is only allowed if the directory is empty.

    中文翻译:

    <库>

    要克隆的(可能是远程的)存储库。有关的更多信息,请参见下面的URLS部分

    指定存储库。

    <目录>

    要克隆到的新目录的名称。如果没有,则使用源存储库的“人性化”部分

    目录是显式给定的(repo for /path/to/repo)。.xz:foo/.git)。克隆到一个

    只有当目录为空时,才允许使用现有目录。

    4.例子,通过上面的帮助信息了解了git clone命令的使用方式,下面来实际操作一下:

    4.1.0使用git clone命令克隆一个存储库

    [root@localhost git]# git clone https://github.com/houdunwang/cart.git cart1

    正克隆到 'cart1'...

    remote: Enumerating objects: 59, done.

    remote: Total 59 (delta 0), reused 0 (delta 0), pack-reused 59

    Unpacking objects: 100% (59/59), done.

    4.1.1打印一下,目录多了一个cart1目录

    [root@localhost git]# ls

    bbs  cart1  edu

    [root@localhost git]# ls cart1/

    composer.json  phpunit.xml  README.md  src  tests

    [root@localhost git]# ls cart1/tests/

    BaseTest.php

    4.1.2此时cart1非空,再次使用刚刚才的命令看看

    [root@localhost git]# git clone https://github.com/houdunwang/cart.git cart1

    fatal: 目标路径 'cart1' 已经存在,并且不是一个空目录。

    [root@localhost git]#

    4.1.3不指定[<directory>]这个可选参数看看

    [root@localhost git]# git clone https://github.com/houdunwang/cart.git

    正克隆到 'cart'...

    remote: Enumerating objects: 59, done.

    remote: Total 59 (delta 0), reused 0 (delta 0), pack-reused 59

    Unpacking objects: 100% (59/59), done.

    [root@localhost git]# ls

    bbs  cart  cart1  edu

    [root@localhost git]#

     注:git clone命令的简单使用,到这里结束,git命令的帮助信息,大家可以看看,完全就是官方文档

    相关文章

      网友评论

          本文标题:1.2 查看Git命令的帮助信息

          本文链接:https://www.haomeiwen.com/subject/beflxctx.html