
- Git 入門
- Git - 首頁
- Git - 版本控制
- Git - 基本概念
- Git - 命令列
- Git - 安裝
- Git - 首次設定
- Git - 基本命令
- Git - 獲取幫助
- Git - 工具
- Git - 速查表
- Git - 術語
- Git 分支
- Git - 簡述分支
- Git - 建立新分支
- Git - 切換分支
- Git - 分支和合並
- Git - 合併衝突
- Git - 管理分支
- Git - 分支工作流程
- Git - 遠端分支
- Git - 跟蹤分支
- Git - 變基
- Git - 變基 vs. 合併
- Git - 合併提交
- Git 操作
- Git - 克隆操作
- Git - 標記操作
- Git - 別名操作
- Git - 提交操作
- Git - 暫存操作
- Git - 移動操作
- Git - 重新命名操作
- Git - 推送操作
- Git - 拉取操作
- Git - Fork 操作
- Git - Patch 操作
- Git - Diff 操作
- Git - 狀態操作
- Git - 日誌操作
- Git - HEAD 操作
- Git - origin master
- Git 撤銷
- Git - 撤銷更改
- Git - checkout
- Git - revert
- Git - reset
- Git - 恢復操作
- Git - rm
- Git - switch 操作
- Git - cherry-pick
- Git - amend
- Git 伺服器端
- Git - 本地協議
- Git - 智慧 HTTP 協議
- Git - 啞 HTTP 協議
- Git - SSH 協議
- Git - Git 協議
- Git - 在伺服器上獲取 Git
- Git - 設定伺服器
- Git - Daemon
- Git - GitWeb
- Git - GitLab
- Git - 第三方託管選項
- 分散式 Git
- Git - 分散式工作流程
- Git - 為專案做貢獻
- Git - 維護專案
- 自定義 Git
- Git - 配置
- Git - 鉤子
- Git - 屬性
- Git - init
- Git - commit
Git - 獲取幫助
Git 自帶一個內建的幫助系統,可以直接從命令列訪問。這些命令對於快速查詢有關特定 Git 命令和選項的資訊非常有用。
git help
命令
git help
命令是訪問 Git 命令文件最直接的方法。它提供了可用命令的概述以及如何使用它們。
$ git help
輸出訊息如下
usage: git [-v | --version] [-h | --help] [-C] [-c = ] [--exec-path[= ]] [--html-path] [--man-path] [--info-path] [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare] [--git-dir= ] [--work-tree= ] [--namespace= ] [--config-env= = ] [ ] These are common Git commands used in various situations: start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize an existing one 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 restore Restore working tree files rm Remove files from the working tree and from the index examine the history and state (see also: git help revisions) bisect Use binary search to find the commit that introduced a bug diff Show changes between commits, commit and working tree, etc 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 commit Record changes to the repository merge Join two or more development histories together rebase Reapply commits on top of another base tip reset Reset current HEAD to the specified state switch Switch branches tag Create, list, delete or verify a tag object signed with GPG 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' and 'git help -g' list available subcommands and some concept guides. See 'git help ' or 'git help ' to read about a specific subcommand or concept. See 'git help git' for an overview of the system.
此命令顯示常用 Git 命令及其簡短說明的列表。您可以使用此列表來確定您需要幫助的命令。
列出所有 Git 命令
以下命令列出所有可能的 Git 命令,包括常用和不常用的命令,併為每個命令提供簡短說明。
$ git help -a $ git help --all
輸出訊息如下
See 'git help' to read about a specific subcommand Main Porcelain Commands add Add file contents to the index am Apply a series of patches from a mailbox archive Create an archive of files from a named tree bisect Use binary search to find the commit that introduced a bug branch List, create, or delete branches bundle Move objects and refs by archive checkout Switch branches or restore working tree files cherry-pick Apply the changes introduced by some existing commits citool Graphical alternative to git-commit clean Remove untracked files from the working tree clone Clone a repository into a new directory commit Record changes to the repository describe Give an object a human readable name based on an available ref diff Show changes between commits, commit and working tree, etc fetch Download objects and refs from another repository format-patch Prepare patches for e-mail submission gc Cleanup unnecessary files and optimize the local repository gitk The Git repository browser grep Print lines matching a pattern gui A portable graphical interface to Git init Create an empty Git repository or reinitialize an existing one log Show commit logs maintenance Run tasks to optimize Git repository data merge Join two or more development histories together mv Move or rename a file, a directory, or a symlink notes Add or inspect object notes pull Fetch from and integrate with another repository or a local branch push Update remote refs along with associated objects range-diff Compare two commit ranges (e.g. two versions of a branch) rebase Reapply commits on top of another base tip reset Reset current HEAD to the specified state restore Restore working tree files revert Revert some existing commits rm Remove files from the working tree and from the index scalar A tool for managing large Git repositories shortlog Summarize 'git log' output show Show various types of objects :
獲取特定命令的幫助
要獲取特定 Git 命令的幫助,您可以使用“git help” 命令後跟命令名稱。此命令將在瀏覽器中顯示手冊頁 (manpage)。
有三種等效的方法可以獲取完整的 Git 命令手冊頁
要訪問git commit 命令的手冊頁幫助,您可以使用以下任何方法
使用git help <command>
要獲取有關特定 Git 命令的詳細幫助,請使用以下語法
$ git help <command>
例如,要獲取有關commit 命令的幫助,請執行
$ git help commit
使用man git-<command>
您可以使用man 命令後跟git-<command> 來檢視特定 Git 命令的手冊頁。
$ man git-commit
使用 git <command> --help
您可以對任何git <command> 使用--help 來獲取特定於該命令的幫助。
$ git commit --help
執行上述命令後,瀏覽器將顯示如下所示的手冊頁。

要簡要概述 Git 命令的選項,請使用git <command> -h(或 git help <command> -h)。這將簡要概述命令的選項以及如何使用它們,而不會深入探討手冊頁。
$ git commit -h
usage: git commit [-a | --interactive | --patch] [-s] [-v] [-u] [--amend] [--dry-run] [(-c | -C | --squash) | --fixup [(amend|reword):] )] [-F | -m ] [--reset-author] [--allow-empty] [--allow-empty-message] [--no-verify] [-e] [--author= ] [--date= ] [--cleanup= ] [--[no-]status] [-i | -o] [--pathspec-from-file= [--pathspec-file-nul]] [(--trailer [(=|:) ])...] [-S[ ]] [--] [ ...] -q, --[no-]quiet suppress summary after successful commit -v, --[no-]verbose show diff in commit message template Commit message options -F, --[no-]file read message from file --[no-]author override author for commit --[no-]date override date for commit -m, --[no-]message commit message -c, --[no-]reedit-message reuse and edit message from specified commit -C, --[no-]reuse-message reuse message from specified commit --[no-]fixup [(amend|reword):]commit use autosquash formatted message to fixup or amend/reword specified commit --[no-]squash use autosquash formatted message to squash specified commit --[no-]reset-author the commit is authored by me now (used with -C/-c/--amend) --trailer add custom trailer(s) -s, --[no-]signoff add a Signed-off-by trailer -t, --[no-]template use specified template file -e, --[no-]edit force edit of commit --[no-]cleanup how to strip spaces and #comments from message --[no-]status include status in commit message template -S, --[no-]gpg-sign[= ] GPG sign commit Commit contents options -a, --[no-]all commit all changed files -i, --[no-]include add specified files to index for commit --[no-]interactive interactively add files -p, --[no-]patch interactively add changes -o, --[no-]only commit only specified files -n, --no-verify bypass pre-commit and commit-msg hooks --verify opposite of --no-verify --[no-]dry-run show what would be committed --[no-]short show status concisely --[no-]branch show branch information --[no-]ahead-behind compute full ahead/behind values --[no-]porcelain machine-readable output --[no-]long show status in long format (default) -z, --[no-]null terminate entries with NUL --[no-]amend amend previous commit --no-post-rewrite bypass post-rewrite hook --post-rewrite opposite of --no-post-rewrite -u, --[no-]untracked-files[= ] show untracked files, optional modes: all, normal, no. (Default: all) --[no-]pathspec-from-file read pathspec from file --[no-]pathspec-file-nul with --pathspec-from-file, pathspec elements are separated with NUL character
從 Git bash 獲取 Git 指南
您可以使用以下命令從 Git Bash 訪問 Git 指南。Git Bash 將顯示各種概念,幫助您開始使用 Git。
$ git help -g
輸出訊息如下
The Git concept guides are: core-tutorial A Git core tutorial for developers credentials Providing usernames and passwords to Git cvs-migration Git for CVS users diffcore Tweaking diff output everyday A useful minimum set of commands for Everyday Git faq Frequently asked questions about using Git glossary A Git Glossary namespaces Git namespaces remote-helpers Helper programs to interact with remote repositories submodules Mounting one repository inside another tutorial A tutorial introduction to Git tutorial-2 A tutorial introduction to Git: part two workflows An overview of recommended workflows with Git 'git help -a' and 'git help -g' list available subcommands and some concept guides. See 'git help' or 'git help ' to read about a specific subcommand or concept. See 'git help git' for an overview of the system.
您可以使用git help 命令後跟指南名稱來訪問 Git Bash 中的任何特定指南。
要訪問git workflows 命令的手冊指南頁,可以使用以下命令
$ git help workflows
執行上述命令後,瀏覽器將顯示如下所示的手冊頁。
