git - 是否所有 git 命令都有空运行选项?

标签 git

是否所有 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 有一个试运行选项)

作为J.C. Hamano summarizes :

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 and git rm allow the -n command-line option to specify dry run, while in git 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/

相关文章:

git - 是否可以注释 "git diff"?

Android 源代码、Git/Repo 和错误 : '.../.repo/repo/.git/clone.bundle' does not look like a v2 bundle file

git - 在 Git 中,我如何区分分支的第一次提交?

不带参数的 Git 获取和 pull

git - 撤消 GIT Stage 并恢复本地更改

php - 如何将 Gitlab Web Hook 设置为部署

git - 将 .gitignore 与 Rider IDE 结合使用

Git 推送到 Azure 失败(RPC 失败)

Git 允许 "push to master"访问 LDAP 帐户中的特定用户

git - 使用 Git Diff 仅在更改的文件上运行 TSLint