是否所有 git 命令都有一个 --dry-run 选项,或者一个可以指示该命令在不实际执行它们的情况下会做什么的选项?
最佳答案
并非每个命令都自然地支持直接试运行。
- git merge 有 its own option (
git merge --no-commit --no-ff
) - 但是git pull does not really need it ('
git fetch origin
', 然后是 'git log master..origin/master
',在git merge origin/master
之前)
(但是git push
有一个试运行选项)
There are things that are not implemented in git because they do not make sense, and there are things that are not implemented in git because nobody had itch to scratch for.
To put it differently, we tend to implement only things that there are actual, demonstrated needs for from real world and only when the addition makes sense as a coherent part of the system.
iboisver评论:
Another thing to be aware of is that commands like
git add
andgit rm
allow the-n
command-line option to specify dry run, while ingit commit
, the-n
option means something completely different.
So be sure to check the man page
git commit -n
:
-n
--no-verify
This option bypasses the pre-commit and commit-msg hooks. See also githooks(5).
关于git - 是否所有 git 命令都有空运行选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2573905/