有没有办法让Git Flow显示其在后台执行的命令?

6
有没有办法让git-flow在执行flow命令之前提前告诉我它将要执行的确切git命令;或者在执行时告诉我?
我只能看到输出和摘要吗?
4个回答

12
您可以使用Git的GIT_TRACE 环境变量来获取执行命令的详细跟踪信息。例如:
GIT_TRACE=true git flow feature start bar

...显示...

trace: exec: 'git-flow' 'feature' 'start' 'bar'
trace: run_command: 'git-flow' 'feature' 'start' 'bar'
trace: built-in: git 'config' '--get' 'gitflow.branch.master'
trace: built-in: git 'branch' '--no-color'
trace: built-in: git 'config' '--get' 'gitflow.branch.develop'
trace: built-in: git 'branch' '--no-color'
trace: built-in: git 'config' '--get' 'gitflow.branch.master'
trace: built-in: git 'config' '--get' 'gitflow.branch.develop'
trace: built-in: git 'config' '--get' 'gitflow.branch.master'
trace: built-in: git 'config' '--get' 'gitflow.branch.develop'
trace: built-in: git 'config' '--get' 'gitflow.origin'
trace: built-in: git 'config' '--get' 'gitflow.prefix.feature'
trace: built-in: git 'branch' '--no-color'
trace: built-in: git 'branch' '-r' '--no-color'
trace: built-in: git 'branch' '--no-color'
trace: built-in: git 'branch' '-r' '--no-color'
trace: built-in: git 'checkout' '-b' 'feature/bar' 'develop'
Switched to a new branch 'feature/bar'

Summary of actions:
- A new branch 'feature/bar' was created, based on 'develop'
- You are now on branch 'feature/bar'

Now, start committing on your feature. When done, use:

     git flow feature finish bar

如果您需要更多细节,可以使用 sh shellxtrace 选项:
在扩展每个简单命令、命令、case 命令、select 命令或算术 for 命令之后,显示 PS4 的扩展值,然后显示命令及其扩展的参数或相关的单词列表。
编辑 git-flow 脚本,并在第一行的 #!/bin/sh 后面添加 set -x。执行上述命令 git flow feature start bar,将显示大量信息(超出了答案中所包含的范围)。

5
使用--showcommands开关,例如:
git flow feature start FEATURENAME --showcommands

1

1
你可以通过查看 源代码 来了解每个命令的作用。它有很好的文档记录,即使不知道 bash 也能理解发生了什么。
实际上,在检查源代码后,似乎确实有一种方法可以记录 git flow 内部使用的命令,至少大部分是这样。该功能是通过 这个提交 引入的,并暗示了一个 show_commands 设置。您应该能够使用 --show_commands 启用它,并打印出它内部使用的大多数 git 命令。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接