Windows git 2.20.1 命令详解

git 命令用于管理源代码版本。

基本用法     详细用法

git clone git://


git [--version] [--help] [-C <path>] [-c <name>=<value>]

[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]

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

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

<command> [<args>]


command 参数

功能 参数 EN 解释 中文翻译 备注
存储库 clone Clone a repository into a new directory 把存储库克隆进新目录
init Create an empty Git repository or reinitialize an existing one 创建空 Git 存储库 (或重新初始化现有的)
remote Manage set of tracked repositories 管理跟踪存储库集
进栈 push Update remote refs along with associated objects 随关联对象更新远程引用
send-pack Push objects over Git protocol to another repository 透过 Git 协议把对象压入另一存储库
引用 for-each-ref Output information on each ref 输出每个引用的信息
reflog Manage reflog information 管理引用日志信息
replace Create, list, delete refs to replace objects 创建 列出 删除引用以替换对象
show-ref List references in a local repository 列出本地存储库中的引用
symbolic-ref Read, modify and delete symbolic refs 读取 修改和删除符号引用
更新 submodule Initialize, update or inspect submodules 初始化 更新 (或检查) 子模块
update-index Register file contents in the working tree to the index 把工作树中的文件内容注册到索引
update-ref Update the object name stored in a ref safely 更新存储在安全引用中的对象名称
获取 fetch Download objects and refs from another repository 从另一存储库下载对象和引用
fetch-pack Receive missing objects from another repository 从另一存储库接收缺失对象
pull Fetch from and integrate with another repository or a local branch 从另一存储库 (或本地分支) 取得并与之集成
签出 checkout Switch branches or restore working tree files 切换分支 (或恢复工作树文件)
checkout-index Copy files from the index to the working tree 把文件从索引拷贝到工作树
分支 branch List, create, or delete branches 列出 创建 (或删除) 分支
filter-branch Rewrite branches 重写分支
quiltimport Applies a quilt patchset onto the current branch 把被子补丁集应用到当前分支
show-branch Show branches and their commits 展示分支及其提交
消息 fmt-merge-msg Produce a merge commit message 产生合并提交消息
interpret-trailers add or parse structured information in commit messages 在提交消息中,添加或解析结构化信息
合并 merge Join two or more development histories together 把两个 (或多个) 开发历史联结到一起
merge-base Find as good common ancestors as possible for a merge 尽可能查找好的共同祖先进行合并
merge-file Run a three-way file merge 运行 3 路文件合并
merge-index Run a merge for files needing merging 运行需要合并的文件的合并
merge-one-file The standard helper program to use with git-merge-index 与 git-merge-index 一起使用的标准帮助程序
merge-tree Show three-way merge without touching index 展示不会触及索引的 3 路合并
mergetool Run merge conflict resolution tools to resolve merge conflicts 运行合并冲突解决工具,以解决合并冲突
rerere Reuse recorded resolution of conflicted merges 重用记录的冲突合并解决方案
索引 add Add file contents to the index 把文件内容添加到索引
index-pack Build pack index file for an existing packed archive 为现有打包存档构建包索引文件
multi-pack-index Write and verify multi-pack-indexes 编写并验证多包索引
rm Remove files from the working tree and from the index 从工作树和索引移除文件
show-index Show packed archive index 展示打包存档索引
编辑 gc Cleanup unnecessary files and optimize the local repository 清理不必要的文件并优化本地存储库
mv Move or rename a file, a directory, or a symlink 移动 (或重命名) 文件 目录 (或符号链接)
reset Reset current HEAD to the specified state 把当前 HEAD 重置到指定状态
审查历史和状态 bisect Use binary search to find the commit that introduced a bug 使用二进制搜索,去查找引入 Bug 的提交
fsck Verifies the connectivity and validity of the objects in the database 验证数据库中对象的连接性和有效性
grep Print lines matching a pattern 打印匹配模式的行
show Show various types of objects 展示对象的各种类型
日志 log Show commit logs 展示提交日志
notes Add or inspect object notes 添加 (或检查) 对象笔记
shortlog Summarize 'git log' output 摘要 Git 日志输出
注解 annotate Annotate file lines with commit information 以提交信息注解文件行
blame Show what revision and author last modified each line of a file 展示上次修改文件每一行的修订版和作者
cat-file Provide content or type and size information for repository objects 提供存储库对象的内容或类型和大小信息
count-objects Count unpacked number of objects and their disk consumption 计数未打包对象数及其磁盘消耗
help Display help information about Git 显示有关 Git 的帮助信息
标签 mktag Creates a tag object 创建标签对象
tag Create, list, delete or verify a tag object signed with GPG 创建 列出 删除 (或验证) 具有 GPG 签名的标签对象
verify-commit Check the GPG signature of commits 校验提交的 GPG 签名
verify-tag Check the GPG signature of tags 校验标签的 GPG 签名
提交 commit Record changes to the repository 把变化记录到存储库
commit-graph Write and verify Git commit-graph files 编写并验证 Git 提交图形文件
commit-tree Create a new commit object 创建新提交对象
get-tar-commit-id Extract commit ID from an archive created using git-archive 从使用 git-archive 创建的存档中提取提交 ID
差异 diff Show changes between commits, commit and working tree, etc 展示提交 (提交和工作树等) 之间的变化
diff-files Compares files in the working tree and the index 比较工作树和索引中的文件
diff-index Compare a tree to the working tree or index 把树与工作树 (或索引) 进行比较
diff-index Compare a tree to the working tree or index 把树与工作树 (或索引) 进行比较
diff-tree Compares the content and mode of blobs found via two tree objects 通过比较 2 树对象,发现斑点的内容和模式
cherry cherry Find commits yet to be applied to upstream 查找尚未被应用于上游的提交
cherry-pick Apply the changes introduced by some existing commits 应用由一些现有提交引入的变化
变化 citool Graphical alternative to git-commit git-commit 的图形替代
request-pull Generates a summary of pending changes 生成挂起变化的摘要
stash Stash the changes in a dirty working directory away 把变化藏匿在脏工作目录中
whatchanged Show logs with difference each commit introduces 展示每次提交引入差异的日志
修剪 prune Prune all unreachable objects from the object database 修剪对象数据库中的所有不可达对象
prune-packed Remove extra objects that are already in pack files 移除已在包文件中的额外对象
微调 range-diff Compare two commit ranges (e.g. two versions of a branch) 比较 2 提交范围 (例如:分支的 2 版本)
rebase Reapply commits on top of another base tip 重新应用在另一基本提示之上的提交
存档 archive Create an archive of files from a named tree 从命名树创建文件存档
archimport Import a GNU Arch repository into Git 把 GNU Arch 存储库导入 Git
bundle Move objects and refs by archive 按存档移动对象和引用
describe Give an object a human readable name based on an available ref 基于可用的引用给予对象人类可读名称
pack-objects Create a packed archive of objects 创建打包对象存档
pack-redundant Find redundant pack files 查找冗余包文件
pack-refs Pack heads and tags for efficient repository access 为高效访问存储库打包头和标签
repack Pack unpacked objects in a repository 把未打包对象打包到存储库中
unpack-file Creates a temporary file with a blob's contents 创建具有斑点内容的临时文件
unpack-objects Unpack objects from a packed archive 从打包存档中解包对象
verify-pack Validate packed Git archive files 验证打包的 Git 存档文件
工作树 clean Remove untracked files from the working tree 从工作树移除未跟踪的文件
mktree Build a tree-object from ls-tree formatted text 从 ls-tree 格式文本构建树对象
read-tree Reads tree information into the index 把树信息读入索引
worktree Manage multiple working trees 管理多个工作树
write-tree Create a tree object from the current index 从当前索引创建树对象
status Show the working tree status 展示工作树状态
通信 daemon A really simple server for Git repositories 非常简单的 Git 存储库服务器
http-backend Server side implementation of Git over HTTP Git 的 HTTP 服务器端实现
update-server-info Update auxiliary info file to help dumb servers 更新辅助信息文件,以帮助转储服务器
接口 gitk The Git repository browser Git 存储库浏览器
gitweb Git web interface (web frontend to Git repositories) Git Web 界面 (Git 存储库的 Web 前端)
gui A portable graphical interface to Git 可移植的 Git 图形界面
instaweb Instantly browse your working repository in gitweb 立即浏览 gitweb 中的工作存储库
反向 name-rev Find symbolic names for given revs 查找给定 rev 的符号名称
rev-list Lists commit objects in reverse chronological order 按反向时间顺序,列出提交对象
rev-parse Pick out and message parameters 挑出并消息参数
CVS cvsexportcommit Export a single commit to a CVS checkout 将单个提交导出到 CVS 签出
cvsimport Salvage your data out of another SCM people love to hate 从让人又爱又恨的另一 SCM 中抢救出你的数据
cvsserver A CVS server emulator for Git 用于 Git 的 CVS 服务器模拟器
电子邮件 am Apply a series of patches from a mailbox 从邮箱应用一系列补丁
apply Apply a patch to files and/or to the index 把补丁应用到文件和/或索引
format-patch Prepare patches for e-mail submission 为电子邮件提交准备补丁
imap-send Send a collection of patches from stdin to an IMAP folder 把补丁集合从标准输入发送到 IMAP 文件夹
mailinfo Extracts patch and authorship from a single e-mail message 从单个电子邮件消息中,提取补丁和作者身份
mailsplit Simple UNIX mbox splitter program 简单的 UNIX mbox 拆分器程序
patch-id Compute unique ID for a patch 计算补丁的唯一 ID
send-email Send a collection of patches as emails 以电子邮件发送补丁集合
导入 导出 fast-export Git data exporter Git数据导出器
fast-import Backend for fast Git data importers 快速 Git 数据导入器的后端
p4 Import from and submit to Perforce repositories 从 Perforce 存储库导入,并提交给 Perforce 存储库
svn Bidirectional operation between a Subversion repository and Git Subversion 存储库和 Git 之间的双向操作
列表 ls-files Show information about files in the index and the working tree 展示有关索引文件和工作树的信息
ls-remote List references in a remote repository 列出远程存储库中的引用
ls-tree List the contents of a tree object 列出树对象的内容
校验 check-attr Display gitattributes information 显示 gitattributes 信息
check-ignore Debug gitignore / exclude files 调试 gitignore/排除文件
check-mailmap Show canonical names and email addresses of contacts 显示联系人的规范名称和电子邮件地址
证书 credential Retrieve and store user credentials 检索和存储用户证书
credential-cache Helper to temporarily store passwords in memory 把口令临时存储在内存中的帮助程序
credential-store Helper to store credentials on disk 把证书存储在磁盘的帮助程序
Shell sh-i18n Git's i18n setup code for shell scripts 用于 Shell 脚本的 Git i18n 设置代码
sh-setup Common Git shell script setup code 通用 Git Shell 脚本设置代码
辅助 config Get and set repository or global options 获取并设置存储库 (或全局选项)
column Display data in columns 在列中显示数据
hash-object Compute object ID and optionally creates a blob from a file 计算对象 ID 并可选地从文件创建斑点
stripspace Remove unnecessary whitespace 移除不必要的空格
var Show a Git logical variable 展示 Git 逻辑变量


功能 命令 文字解释 示例 示例解释
帮助 git --help 展示帮助信息
git help -a 展示所有帮助信息
git help -g 展示所有指导教程列表信息
版本 git --version 展示版本信息


更新时间: 2020.03.22

版权声明: 本文为独家原创稿件,版权归 乐数软件 ,未经许可不得转载;否则,将追究其法律责任。