【问题标题】:default git commit behavior to --allow-empty默认 git 提交行为为 --allow-empty
【发布时间】:2022-10-21 23:20:45
【问题描述】:

我想让git commit 默认拥有--allow-empty 标志(不使用别名)。

我在git documentation 中搜索,但没有找到任何相关信息。

是否有任何gitconfig 命令可以改变这一点?

【问题讨论】:

  • 我不确定,但作为一种解决方法,您可以为此设置一个 git 别名。
  • @lucidbrot 它可以工作,但我没有将命令本身默认为 --allow-empty
  • 我很想看看是否有人为您的特定问题找到答案。出于好奇:为什么要更改默认命令而不是别名?
  • 顺便说一句:你总是可以拉 git 源代码,自定义处理提交的函数,并为自己构建一个新的二进制文件。
  • 它只是使用真正的命令而不是别名。别名会迫使您再记住一个命令,当您有很多命令时,这很快就会变得困难。

标签: git commit


【解决方案1】:

s 快速浏览一下git-commitgit-config 文档并没有发现这样一个特定的选项。

但是,您可以指定一个 git alias 来执行此操作:

# the --gsobal flag means this works now everywhere, not just in the current repo.
git config --global alias.commit "commit --allow-empty"
# Now use like this:
git commit -m "my empty commit, with a message"

在我写这个答案的时候,这个问题被编辑了。为了完整起见,我将其留在这里,因为未来的访客可能会对此感到满意。

我尝试覆盖alias.commit 本身,而不需要额外的t。这似乎没有任何效果。

【讨论】:

  • @DevinRhode 什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-04-05
  • 1970-01-01
  • 2014-11-25
  • 1970-01-01
  • 1970-01-01
  • 2012-01-25
  • 2010-10-14
相关资源
最近更新 更多