【问题标题】:git list all available commandsgit 列出所有可用的命令
【发布时间】:2011-10-23 13:16:30
【问题描述】:

是否有命令可以显示 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.

我只想列出没有描述。

【问题讨论】:

    标签: git ubuntu


    【解决方案1】:

    试试:

    git help -a
    

    【讨论】:

    • 它不是我所期望的 100%,但它比我发现的要好 +1
    • @skowron-line:这是所有可用 git 命令的列表,没有描述。这不是你要求的吗?
    • +1 非常好 :) “$PATH 上其他地方提供的 git 命令”底部的部分特别有用。
    • @manojlds:它们是 git 安装之外的其他命令,您可以通过 git 调用它们,因为它们开始 git-。如果您没有任何此类命令,那么您将看不到该部分。这不重要。
    • 注意,你可以做git help help。以防万一不记得具体的选项。
    【解决方案2】:

    如果您使用的是 linux (BASH)。你可以试试

    `$ git [TAB] [TAB]`

    然后我得到了这样的东西:

    $混帐 添加 fetch rebase 我是 fetchavs reflog 注释过滤器分支重新链接 应用格式补丁远程 归档 fsck 重新打包 平分 gc 替换 责备 get-tar-commit-id 请求-拉取 br grep 重置 分支 gui 还原 捆绑帮助 rm 结帐 imap-发送短日志 樱桃初始化秀 樱桃采摘 instaweb 显示分支 ci log st citool log1阶段 清理合并存储 克隆合并工具状态 co mv 子模块 提交名称-rev svn 配置注释标签 描述 pull whatchanged 差异推送 difftool pushav

    【讨论】:

    • 我想你会发现它使用了git help -a。
    • 这不是可用命令的完整列表,例如ls-remote 不见了。
    • 您是否必须先启用Git command Auto-Completion 才能使其真正起作用?
    【解决方案3】:

    正如@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。享受吧!

    【讨论】:

    【解决方案4】:

    列出 git 命令,包括 $PATH 上其他地方可用的 git 命令

    git help -a
    

    要列出用户配置的别名,请使用

    git aliases
    

    【讨论】:

      【解决方案5】:

      克隆网址命令:git clone url

      检查状态的命令:git status

      添加文件命令:git add pom.xmlgit add src/

      用消息提交代码的命令:git commit -m "initial version"

      推送命令:git push -u origin master

      清除 git 终端的命令:clear

      检查不同分支的命令:git checkout -b branch-name

      添加文件的命令:git add src/main/java/com/rest/mongo/UserExample.java

      从不同分支拉取更新的命令:git pull origin develop

      通过上游推送的命令:git push --set-upstream origin 11111feature-234

      将您的分支合并到开发/主分支的步骤:git checkout -b develop git merge your-branch-name

      以下链接供参考使用:(逐步解释)

      https://www.youtube.com/watch?v=tzZj-bnjX6w&t=17s

      【讨论】:

        【解决方案6】:

        来源:https://thenucleargeeks.com/2020/01/20/git-commands-cheat-sheet/

        Windows: Use Chocolatey and in powershell type
        
        choco install git
        Linux:
        
        ubuntu: sudo apt-get update && sudo apt-get install git -redhat: sudo yum install git -h
        Mac OS:
        
        install Homebrew and Xcode
        Set a user name which can be seen or associated with every commit
        
        git config --global user.name "nuclear geeks"
        Set a user email which can we seen or associated with every commit
        
        git config --global user.email "nucleargeeks18@gmail.com"
        Clone an existing repository
        
        git clone url
        Check the modified file in working directory.
        
        git status
        Add a modified file to staging area.
        
        git add <file_name>
        Add all the modified file to staging area
        
        git add . 
        Commit message
        
        git commit -m "commit_message"
        Difference between working area and staging
        
        git diff <file_name>
        Difference between working area and last commit or repository
        
        git diff HEAD <file_name>
        Difference between staging area and repository
        
        git diff --staged 
        git diff --staged <file_name>
        List all your branches
        
        git branch 
        Create new branch
        
        git checkout -b <branch_name>
        Push the branch to origin
        
        git push origin <branch_name>
        Switch to another branch
        
        git checkout <branch_name>
        Merge branches
        
        git merge <branch_name>
        Backout File, If you want to move your file from stage area to working or unstage area
        
        git reset HEAD <file_name>
        Discard changes in working directory
        
        git checkout <file_name>
        Delete file
        
        git rm <file_name>
        Rename a file
        
        git mv <current_name> <new_name>
        Move a file
        
        git mv <file_name> <dir_name>
        Git alias, renaming command to new name
        
        git config -global alias. <short_command> <"long command">
        Find hidden file
        
        git ls -al 
        Stash your changes
        
        git stash
        To apply your changed from stash
        
        git stash apply
        To delete your stash from the list
        
        git stash drop
        To list your stash list
        
        git stash list 
        To apply the changes and delete from the listt
        
        git stash pop
        Git stash with message
        
        git stash save "msg"
        Find change done in specific index
        
        git stash show stash@{id}
        Apply
        
        git stash apply stash@{id}
        Tag creation
        
        git tag <tag_name>
        Annotated tag creation
        
        git tag -a <tag_name>
        Push tag to remote
        
        git push origin <tag_name>
        List all the tags
        
        git tag --list
        Delete tags
        
        git tag --delete <tag_name>
        Create a branch from the tag
        
        git checkout -b <branch_name> <tagname>
        Create a tag from past commit
        
        git tag <tag_name> <reference_of_commit>
        

        【讨论】:

          【解决方案7】:

          在 Git 2.36(2022 年第二季度)中,“git help -a”(man) 具有有助于过滤/澄清命令列表的新选项。

          请参阅commit 93de1b6、commit 1ce5901、commit 503cdda、commit 5e8068b、commit d7f817d、commit 6fb427a、commit bf7eed7、commit cd87ce7、commit 4bf5cda(2022 年 2 月 21 日)@9876。 br>(由 Junio C Hamano -- gitster -- 合并于 commit 1f3c5f3,2022 年 3 月 9 日)

          help:添加--no-[external-commands|aliases] 与--all 一起使用

          签字人:Ævar Arnfjörð Bjarmason

          在--all下添加仅发出git自己的使用信息的能力。

          这也允许我们扩展在前面的提交中添加的"test_section_spacing" 测试以测试“git help --all”(man) 输出。

          以前我们不能这样做,因为测试可能会在“$PATH”中找到一个 git-* 命令,这会使输出因一种设置而异。

          git help 现在包含在其man page 中:

          'git help' [-a|--all] [--[no-]verbose] [--[no-]external-commands] [--[no-]aliases]

          git help 现在包含在其man page 中:

          --no-external-commands

          与--all 一起使用时,排除外部“git-*”的列表 在$PATH 中找到的命令。

          --no-aliases

          与--all一起使用时,排除已配置的列表 别名。

          【讨论】:

            猜你喜欢
            • 2010-10-31
            • 2014-04-05
            • 2020-04-24
            • 2018-04-23
            • 2020-03-29
            • 1970-01-01
            • 1970-01-01
            • 2015-01-29
            • 1970-01-01
            相关资源
            最近更新 更多