我怎样才能找到git-bash.exe的命令行选项?

显然我的谷歌搜索能力很差... 我从其他StackExchange的帖子中了解到以下内容:
--cd-to-home    # Change directory to home
--cd=<path>     # Change directory to <path>
-i              # ?
-c              # Run command, but --command doesn't work/exist
在哪里可以找到git-bash.exe(终端模拟器)的完整选项列表?我找到了mintty的选项列表[1],但它们似乎不是适用于git-bash.exe的正确选项...
更新: 所以 `git-bash.exe` 似乎只是一个简单的包装器,首先解析 `--cd...` 选项,然后运行。
usr\bin\mintty.exe --icon git-bash.exe,0 --exec "/usr/bin/bash" --login -i <other arguments>
或类似的。这就是为什么只有--cd..和bash选项被正确解析,而不是mintty。 如果你想使用mintty的其他选项,你应该使用一个类似的命令,而不是试图用git-bash.exe来做。例如:
usr\bin\mintty.exe --icon git-bash.exe,0 --window full --exec "/usr/bin/bash" --login -i -c "echo 'Hello World!'; read"

你尝试过以help开始吗?如果它的使用方式类似于Linux下的命令行git,你可以询问git --help -a以获得完整的命令列表。 - Hastur
[所] 重复:Git Bash 命令快速参考 - DavidPostill
1git-bash.exe是终端仿真器(基于mintty),它具有一系列标准命令,如lsgit(基于msys)。我知道如何获取这些命令的选项,但我正在寻找终端仿真器的选项。我还尝试过git-bash.exe --helpgit-bash.exe /?,但都没有显示任何内容。 - 816-8055
7@DavidPostill 不是重复问题 - 这个问题要求提供用于调用shell命令的命令行选项 - gt6989b
3把你的编辑移到答案中并将其标记为答案可能是值得的。 - dumbledad
5个回答

我找到了这个来自2015年的提交,它引入了新的命令行选项: https://github.com/git/git/commit/ac6b03cb4197311b055dc5f46ab10bf37c591ae6 以下是提交描述中的列表:
--command=<command-line>::
    Executes `<command-line>` instead of the embedded string resource

--[no-]minimal-search-path::
    Ensures that only `/cmd/` is added to the `PATH` instead of
    `/mingw??/bin` and `/usr/bin/`, or not

--[no-]needs-console::
    Ensures that there is a Win32 console associated with the spawned
    process, or not

--[no-]hide::
    Hides the console window, or not
您可以在上面的URL中阅读完整信息。

正确的,git-bash.exe没有命令行选项帮助列表。我自己花了一些时间寻找它们,但没有找到任何适当的文档。它似乎是bin/sh.exe的包装器。如果你真的需要做更多的事情,我建议查看sh.exe的帮助信息。

4啊,是的,这些选项像-c-i--login等看起来都很准确。这里有一个在线手册页。我主要想知道-i选项是做什么用的。--cd-to-home--cd不是sh命令(mintty也不是),所以我猜它们是为了方便而添加的,不知道还有没有其他的... 附注:还有C:\Program Files\Git\usr\bin\mintty.exe - 816-8055
同样适用于git-cmd.exe,没有文档和ConEmu传递的参数--no-cd和--command与cmd.exe无关。 - user1708042

我也在想如何获取命令行选项,然后通过谷歌搜索找到了这个帖子。 我发现这些选项在git的文档中有记录。 调用:
git help git-bash
并且它将在您的浏览器中打开一个git-bash手册页面,解释所有选项。

哇,谢谢,这就是我想要的。我从来没有想过在 git 文档本身中寻找工具文档... - 816-8055

这是你在启动git-bash.exe(版本为2.8.1)时找到的命令行。
usr\bin\mintty.exe -o AppID=GitForWindows.Bash -o RelaunchCommand="C:\Git\git-bash.exe" -o RelaunchDisplayName="Git Bash" -i /mingw32/share/git/git-for-windows.ico /usr/bin/bash --login -i

只需键入bash.exe --help,它就会显示一个包含所有选项的屏幕。 示例:
$ bash.exe --help

GNU bash, version 4.4.23(1)-release-(x86_64-pc-msys)
Usage:  bash [GNU long option] [option] ...
        bash [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --protected
        --rcfile
        --restricted
        --verbose
        --version
        --wordexp
Shell options:
        -ilrsD or -c command or -O shopt_option         (invocation only)
        -abefhkmnptuvxBCHP or -o option
Type `bash -c "help set"' for more information about shell options.
Type `bash -c help' for more information about shell builtin commands.
Use the `bashbug' command to report bugs.

bash home page: <http://www.gnu.org/software/bash>
General help using GNU software: <http://www.gnu.org/gethelp/>

3"bash.exe"和"git-bash-exe"是完全不同的可执行文件。问题是关于后者。如果你还在的话,你应该删除这个回答,否则你会得到更多的负评,@joe mama。 - spechter
即使在这里也没有充分解释bash选项,例如-i选项根本没有描述(_我正在寻找bash并来到了这里。但我知道这不是讨论的地方._)。 - kca