默认 git 提交行为为 --allow-empty

问题描述 投票:0回答:1

我想让

git commit
默认具有
--allow-empty
标志(不带别名)。

我在 git 文档中搜索,但没有找到任何相关内容。

是否有任何

git config
命令可以更改此设置?

git commit
1个回答
1
投票

快速浏览 git-commitgit-config 文档并没有揭示这样一个特定的选项。

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

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

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

我尝试覆盖

alias.commit
本身,而不添加额外的
t
。这似乎没有任何效果。

© www.soinside.com 2019 - 2024. All rights reserved.