章節 ▾ 第二版

1.7 入門 - 獲取幫助

獲取幫助

如果您在使用 Git 時需要幫助,有三種等效的方式可以獲取任何 Git 命令的全面手冊頁(manpage)幫助。

$ git help <verb>
$ git <verb> --help
$ man git-<verb>

例如,您可以透過執行以下命令來獲取 git config 命令的手冊頁幫助:

$ git help config

這些命令很方便,因為您可以在任何地方訪問它們,即使離線也能使用。如果手冊頁和本書都不夠,並且您需要面對面的幫助,您可以嘗試 Libera Chat IRC 伺服器上的 #git#github#gitlab 頻道,您可以在 https://libera.chat/ 找到它。這些頻道通常有數百名非常瞭解 Git 的使用者,並且他們很樂意提供幫助。

此外,如果您不需要完整的manpage幫助,只是需要快速回顧 Git 命令的可用選項,您可以使用 -h 選項來請求更簡潔的“幫助”輸出,例如:

$ git add -h
usage: git add [<options>] [--] <pathspec>...

    -n, --dry-run               dry run
    -v, --verbose               be verbose

    -i, --interactive           interactive picking
    -p, --patch                 select hunks interactively
    -e, --edit                  edit current diff and apply
    -f, --force                 allow adding otherwise ignored files
    -u, --update                update tracked files
    --renormalize               renormalize EOL of tracked files (implies -u)
    -N, --intent-to-add         record only the fact that the path will be added later
    -A, --all                   add changes from all tracked and untracked files
    --ignore-removal            ignore paths removed in the working tree (same as --no-all)
    --refresh                   don't add, only refresh the index
    --ignore-errors             just skip files which cannot be added because of errors
    --ignore-missing            check if - even missing - files are ignored in dry run
    --sparse                    allow updating entries outside of the sparse-checkout cone
    --chmod (+|-)x              override the executable bit of the listed files
    --pathspec-from-file <file> read pathspec from file
    --pathspec-file-nul         with --pathspec-from-file, pathspec elements are separated with NUL character