Ответ 1
Try:
git help -a
Есть ли команда, которая может показать мне список всех доступных команд в GIT? Существует git help
, но он показывает:
usage: git [--version] [--exec-path[=<path>]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=<path>] [--work-tree=<path>]
[-c name=value] [--help]
<command> [<args>]
The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
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 matching a pattern
init Create an empty git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories together
mv Move or rename a file, a directory, or a symlink
pull Fetch from and merge with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete or verify a tag object signed with GPG
See 'git help <command>' for more information on a specific command.
И я хочу просто список без описания.
Try:
git help -a
Если вы используете linux (BASH). Вы можете попробовать
`$ git [TAB] [TAB]`
Затем я получил что-то вроде этого:
$ git add fetch rebase am fetchavs reflog annotate filter-branch relink apply format-patch remote archive fsck repack bisect gc replace blame get-tar-commit-id request-pull br grep reset branch gui revert bundle help rm checkout imap-send shortlog cherry init show cherry-pick instaweb show-branch ci log st citool log1 stage clean merge stash clone mergetool status co mv submodule commit name-rev svn config notes tag describe pull whatchanged diff push difftool pushav
Как уже предположил @CharlesBailey, git help -a
- отличный способ перечислить все подкоманды, которые предлагает git. Однако, если вы хотите удалить часть форматирования, которую печатает git, это также можно сделать:
Самый простой способ получить список всех подкоманд git выглядит следующим образом:
git help -a | grep "^ [a-z]" | tr ' ' '\n' | grep -v "^$"
Это выводит результат git help -a
, выбирает только отступы, преобразует пробелы в символы новой строки, а затем удаляет пустые строки.
Зачем вам это нужно? Общей причиной того, что вы хотите перечислить подкоманды команды, является включение автозаполнения в Bash:
complete -W "$(git help -a | grep "^ [a-z]")" git
Теперь, когда вы набираете git br
и нажимаете TAB
, он автоматически заполняется до git branch
. Наслаждайтесь!
почему бы не перечислить все файлы в каталоге git -core?
i означает ls -1 [the git core directory]