git 列出所有可用命令
是否有命令可以显示 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.
而且我只想列出没有描述的内容。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
尝试:
Try:
正如 @CharlesBailey 已经建议的那样,
git help -a
是列出 git 提供的所有子命令的好方法。但是,如果您想删除 git 打印的一些格式,也可以这样做:获取所有 git 子命令列表的最简单方法如下:
这需要 git help -a 的输出code>,仅选择缩进的行,将空格转换为换行符,然后删除空行。
你为什么想要这样的东西?想要列出命令的子命令的一个常见原因是在 Bash 中启用自动补全:
现在,当您输入
git br
并按TAB
时,它会自动补全为git 分支
。享受!As @CharlesBailey already suggested,
git help -a
is a great way to list all of the subcommands that git offers. However, if you want to remove some of the formatting that git prints, that can be done too:The easiest way to get a list of all git subcommands is as follows:
This takes the output of
git help -a
, selects only the lines that are indented, converts spaces to newline characters, and then removes the empty lines.Why would you want something like this? A common reason for wanting to list the subcommands of a command is to enable autocompletion in Bash:
Now, when you type
git br
and pressTAB
, it autocompletes togit branch
. Enjoy!您可以使用
git
的--listcmds
参数:制表符补全引用在另一个答案中似乎使用以下内容来生成其列表(在
/usr/share/bash-completion/completions/git
中找到):请注意此参数的文档:
You can use the
--listcmds
argument togit
:The tab completion referred to in another answer seems to use the following to generate its list (found in
/usr/share/bash-completion/completions/git
):Do note the caveat in the documentation of this parameter:
如果您使用的是 Linux (BASH)。你可以尝试
然后我得到了这样的东西:
If you are using linux (BASH). You can try
Then I got something like this:
要列出 git 命令,包括 $PATH 上其他地方可用的 git 命令
要列出用户配置的别名,请使用
To list git commands, inluding git commands available from elsewhere on your $PATH
To list user-configured aliases use
使用 Git 2.36(2022 年第 2 季度),“
git help -a
"(man) 有新选项,有助于过滤/澄清命令列表。请参阅 提交 93de1b6,提交 1ce5901, 提交 503cdda, 提交 5e8068b, 提交 d7f817d, 提交 6fb427a, 提交 bf7eed7, 提交 cd87ce7, 提交 4bf5cda(2022 年 2 月 21 日),作者:Ævar Arnfjörð Bjarmason (
avar
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 1f3c5f3,2022 年 3 月 9 日)git help
现在包含在其 手册页:git help
现在包含在其 手册页:With Git 2.36 (Q2 2022), "
git help -a
"(man) has new options which helps filter/clarify the list of commands.See commit 93de1b6, commit 1ce5901, commit 503cdda, commit 5e8068b, commit d7f817d, commit 6fb427a, commit bf7eed7, commit cd87ce7, commit 4bf5cda (21 Feb 2022) by Ævar Arnfjörð Bjarmason (
avar
).(Merged by Junio C Hamano --
gitster
-- in commit 1f3c5f3, 09 Mar 2022)git help
now includes in its man page:git help
now includes in its man page:来源:https://thenucleargeeks.com/2020/01/20 /git-commands-cheat-sheet/
Source: https://thenucleargeeks.com/2020/01/20/git-commands-cheat-sheet/
我知道这是一个古老的问题并且已经得到了解答,但我最近在寻找一些操纵器时遇到了这个难题,并发现它们没有被 git 的 bash 补全列出。
传递参数:
到“git --list-cmds”将生成 git 可用的每个命令的列表如下例所示。
我还为 bash 补全编写了一个补丁,因此当您输入 git [tab][tab] 时,它实际上会显示所有可用的命令,即使并非每个命令都有特定命令的参数补全.
当你忘记像 ls-tree 这样的东西时,它非常方便。
I know this is an ancient question and it has already been answered, but I recently ran into this conundrum while looking for some of the manipulators and saw that they weren't being listed by the bash completions for git.
Passing the arguments:
to "git --list-cmds" will produce a list of every command git has available as seen in the example below.
I've also written a patch for the bash completions as well so when you type out git [tab][tab] it will actually show all the commands available even if not every one of them has argument completion for the specific command.
It's quite handy when you forget things like ls-tree.
克隆 url 的命令:
git clone url
检查状态的命令:
git status
添加文件的命令:
git add pom.xml
git添加 src/
命令提交代码并带有消息:
git commit -m "initial version"
命令推送:
git push -u origin master
命令清除 git终端:
clear
命令来签出不同的分支:
git checkout -bbranch-name
命令添加文件:
git add src/main/java/com/rest/mongo/UserExample.java
命令从不同分支提取更新:
git pull origindevelop
命令推送到上游:
git push --set-upstream origin 11111feature-234
将分支合并到develop/master分支的步骤:
git 结帐-b开发
git merge your-branch-name
参考以下链接:(逐步说明)
https://www.youtube.com/watch?v=tzZj-bnjX6w&t=17s
command for clone url:
git clone url
command to check status:
git status
command to add file:
git add pom.xml
git add src/
command to commit code with message:
git commit -m "initial version"
command to push:
git push -u origin master
command to clear git terminal:
clear
command to checkout different branch:
git checkout -b branch-name
command to add file:
git add src/main/java/com/rest/mongo/UserExample.java
command to pull updates from different branch:
git pull origin develop
command to push through upstream:
git push --set-upstream origin 11111feature-234
steps to merge your branch to develop/master branch:
git checkout -b develop
git merge your-branch-name
for reference use below link:(step by step explanation)
https://www.youtube.com/watch?v=tzZj-bnjX6w&t=17s