• github之git基本命令介绍的简单整理


    git 格式:

    git [--version] [--exec-path[=<path>]] [--html-path] [--info-path]

         [-p|--paginate|--no-pager] [--no-replace-objects] [-bare]

         [--git-dir=<path>] [--work-tree=<path>][--namespace=<name>]

         <command> [<args>]

    最常用的git命令解说如下:

    add    

    说明:git add <path> 添加文件内容到索引库,文件内容包括新添或修改(不包括已删除)的文件,并把它们的信息添加到索引库中。注:省略<path>,说明是当前目录;

    Description:

     git add -u [<path>]   #把<path>中所有tracked文件中被修改过或已删除文件的信息添加到索引库。它不会处理untracted的文件。

    git add -A:  [<path>]   #把<path>中所有tracked文件中被修改过或已删除文件和所有untracted的文件信息添加到索引库。

    git add -i [<path>]     #查看<path>中被所有修改过或已删除文件但没有提交的文件,过其revert子命令可以查看<path>中所有untracted的文件,同时进入一个子命令系统。

    详情查看:http://blog.csdn.net/joe_007/article/details/7889173

    bisect 

    说明:Find by binary search the change that introduced a bug,大意是说通过二分查找的方式快速定位引入Bug的版本;

    Eg:git bisect <subcommand> <options>

    git bisect help
    git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<paths>...]
    git bisect bad [<rev>]
    git bisect good [<rev>...]
    git bisect skip [(<rev>|<range>)...]
    git bisect reset [<commit>]
    git bisect visualize
    git bisect replay <logfile>
    git bisect log
    git bisect run <cmd>...

    详情可参考以下文章

    https://www.kernel.org/pub/software/scm/git/docs/git-bisect.html

    http://crazycode.iteye.com/blog/311564

    http://git-scm.com/docs/git-bisect

    branch 

    说明:List,Create,or delete  branches ;

    Eg:

        git branch       #查看当前分支的状态

    checkout 

    说明:Checkout a branch or paths to the working tree ;

    Eg1:

        检出命令git checkout是git最常用的命令之一,同时也是一个很危险的命令,因为这条命令会重写工作区。检出命令的用法如下:

        用法一:git checkout [-q] [<commit>] [--] <paths>...

        用法二:git checkout [<branch>]

        用法三:git checkout [-m] [[-b]--orphan] <new_branch>] [<start_point>]

    Eg2:

      正确切换分支的思路

      如果本地分支存在问题,需要删除,有两种方式

      第一种:git  branch -d   <branch_name>    # 删除分支,如果还存在未提交的代码,可能会删除失败

      第二种:git  branch -D  <branch_name>     # 强制删除本地分支

      切换分支的两种场景:

      第一种:git checkout   <branch_name>      # 切换到本地已经存在的分支上去

      第二种:git checkout  -b <branch_name>   # 切换到指定分支上,如果该分支不存,则基于当前分支,创建新分支

      第三种:git  checkout -b <new_branch_name>  <origin_branch_name>  # 基于分支<origin_branch_name>创建新的本地分支,并切换到该分支上;

          eg: git checkout -b develop origin/develop    # 基于远程分支“origin/develop“,创建本地新分支“develop”

    详情参考:http://www.cnblogs.com/craftor/archive/2012/11/04/2754147.html

    clone:

    说明:Clone  a repository into a new directory ; 

    详细参考:http://blog.csdn.net/hudashi/article/details/7664396

    commit:

    说明:Record changes to the repository;

    使用实例:

    diff:

    说明:Show changes between commits , commit and working tree,etc;

    使用实例:

    fetch:

    说明:Download objects  and refs  from another repository ;

    使用实例:

    grep:

    说明:print lines matcing a pattern ;

    Eg:

    详情参考:http://git-scm.com/docs/git-grep

    init:

    说明:Create an ampty git repository or reinitialize  an existing one ;

    log:

    说明:Show commit logs ;

    merge:

    说明:Join two or more development historise  together ;

    Eg:

    mv: 

    说明:Move  or rename a file , a directory, or a symlink ;

    使用实例:

    pull:

    说明:Fetch from and merge with another repository or a local branch ;

    Eg:

    push:

    说明:Update remote refs along with associated  objects ;

    Eg:

    rebase:

    说明:Forward-port local commits to the updated upstream head ;

    使用实例:

    reset:

    说明:Reset current HEAD to the specified stated ;

    rm:

    说明:Remove files from the working tree and from the index ;

    show:

    说明:Show various types of  objects ;

    status:

    说明:Show the working types of objects ;

    tag:

    说明:Create,list,delete or verify a tag object signed with GPG;

    以上使用详情,可参考官方文档:http://git-scm.com/docs/

  • 相关阅读:
    【JZOJ4928】【NOIP2017提高组模拟12.18】A
    【JZOJ4922】【NOIP2017提高组模拟12.17】环
    【JZOJ4923】【NOIP2017提高组模拟12.17】巧克力狂欢
    【JZOJ4924】【NOIP2017提高组模拟12.17】向再见说再见
    【JZOJ4919】【NOIP2017提高组模拟12.10】神炎皇
    【JZOJ4920】【NOIP2017提高组模拟12.10】降雷皇
    【JZOJ4921】【NOIP2017提高组模拟12.10】幻魔皇
    【罗宾欺诈者】回环符文——回文树(回文自动机)
    【怪物】KMP畸形变种——扩展KMP
    【51NOD1304】字符串的相似度
  • 原文地址:https://www.cnblogs.com/outpointexception/p/3633648.html
Copyright © 2020-2023  润新知