zoukankan      html  css  js  c++  java
  • Git 命令行帮助

    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>]
    
    # 这些是在各种情况下使用的常见Git命令:
    These are common Git commands used in various situations:
    
    # 启动一个工作区域(另请参阅:git help tutorial)
    start a working area (see also: git help tutorial)
       # 将存储库克隆到新目录中
       clone      Clone a repository into a new directory
       # 创建一个空的Git存储库或重新初始化现有的存储库
       init       Create an empty Git repository or reinitialize an existing one
    
    # 在当前的变化上工作(另请参阅:git help everyday)
    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
       # 将当前HEAD重置为指定状态
       reset      Reset current HEAD to the specified state
       # 从工作树和索引中删除文件
       rm         Remove files from the working tree and from the index
    
    # 检查历史和状态(另请参阅:git help revisions)
    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
       # 创建,列出,删除或验证使用GPG签名的标签对象
       tag        Create, list, delete or verify a tag object signed with GPG
    
    # 协作(另请参阅:git help workflows)
    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'和'git help -g'列出可用的子命令和一些
    概念指南。 请参阅'git help <command>'或'git help <concept>'
    阅读有关特定的子命令或概念。
    '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.
    

    从命令行创建一个新的仓库

    touch README.md
    git init
    git add README.md
    git commit -m "first commit"
    git remote add origin http://192.168.0.240:3000/useadmin/Null.git
    git push -u origin master
    

    从命令行推送已经创建的仓库

    git remote add origin http://192.168.0.240:3000/useadmin/Null.git
    git push -u origin master
    

    暂存->拉取->恢复暂存

    git stash
    git pull
    git stash pop
    
    # 远程代码和本地代码合并
    git pull --rebase origin master
    git push -u origin master
    
    # 强制推送
    git push -f
    
    
    git fetch
    git merge
    上面两句等价于
    git pull 
    
    .gitignore 文件如何在 window 上创建?
    .gitignore. 文件名两边都有一个点即可创建
    # 注释
    xxx 黑名单
    !xxx 白名单
    
    dos 命令行
    copy nul .gitignore
    
    如何删除 git add 添加到缓存中文件?
    
    
    git rm -r -n --cached 文件/文件夹名称  ,预览将要删除的文件
    
    一种是 git rm --cached "文件/文件路径",不删除物理文件,仅将该文件从缓存中删除;
    
    一种是 git rm --f  "文件/文件路径",不仅将该文件从缓存中删除,还会将物理文件删除(不会回收到垃圾桶)。
    
    error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400 Failed reading client body
    fatal: The remote end hung up unexpectedly
    //设置 post 缓冲区大小 5G
    git config --global http.postBuffer 5242880000
    git config --global https.postBuffer 5242880000
    # 查看设置
    git config --list
    
    合并分支
    git fetch origin master
    git merge origin/master
    

    递归遍历

    git clone --recursive https://github.com/caffe2/caffe2.git
    
    git reset xxx --hard
    git reflog
    git reset old_xxx--hard
    
    # 更新子模块
    git submodule init
    git submodule update
    或
    git submodule update --init --recursive
    
    # 添加子模块
    git submodule add <url> <path>
    
    git submodule add <url> ./3rdparty/submodule_name
    
    git submodule add -b master --force <url> <path>
    
  • 相关阅读:
    linux gcc安装
    重装win7后如何恢复ubuntu引导
    Eclipse搭建Android开发环境(安装ADT,Android4.4.2)
    mysql变量使用总结
    最快得到MYSQL两个表的差集
    mysqldb
    更改时间 (时分秒)
    使用命令转移文件
    报喜啦~过了!
    Jmeter接口测试示例
  • 原文地址:https://www.cnblogs.com/cheungxiongwei/p/8549740.html
Copyright © 2011-2022 走看看