所有的git命令都有一个干运行选项吗? [英] Do all git commands have a dry-run option?

查看:255
本文介绍了所有的git命令都有一个干运行选项吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有的git命令都有一个--dry-run选项,或者一个可以指示命令在没有实际执行的情况下会执行什么操作的选项?

解决方案<





由于 JC Hamano总结了一下:


有些东西在git中没有实现,因为它们没有使
有意义,有一些东西在git中没有实现,因为没有
的东西可以搔痒。

换句话说,我们倾向于只实现
的东西,这些东西存在实际的需求对于真实世界和
而言,只有当增加作为系统的连贯部分才有意义。






iboisver 评论:


另外需要注意的是,像 git add git rm 允许 -n 命令行选项指定空运行,而在 -n c $ c>选项意味着完全不同的东西。

所以一定要检查手册页


git commit -n

  -n 
--no-验证




此选项绕过预先提交和提交msg挂钩。另请参阅 githooks(5)



Do all git commands have a --dry-run option, or one which would indicate what the command would do without actually doing them?

解决方案

Not every command would naturally support a dry run directly.

  • git merge has its own option (git merge --no-commit --no-ff)
  • but git pull does not really need it ('git fetch origin', then a 'git log master..origin/master', before a git merge origin/master)
    (but git push has a dry-run option)

As 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 comments:

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命令都有一个干运行选项吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆