`git push --force-with-lease` 的短标志?
Short flag for `git push --force-with-lease`?
在大多数情况下,我已经开始使用 git push --force-with-lease
而不是 --force
来进行额外的分支保护:
- git push --force-with-lease vs. --force
我什至可以尝试将此选项设置为默认选项,如下所述:
虽然使用 --force-with-lease
的主要烦恼是输入该标志的笨拙的措辞和冗长的语法。
Git 的 --force
和 -f
标志更短且更易于键入,但不提供额外的安全性。
有没有--force-with-lease
的简写形式,比如--fwl
?
- 如果没有,是否有未添加的原因?一个更方便的标志似乎会增加对更安全功能的采用。 git 的创建者讨论过这个问题吗?
如果默认情况下不存在这样的标志,我如何在自己的机器上创建这样的标志或别名?
该选项没有 shorthand。要 make a global alias,只需将此添加到 ~/.gitconfig
[alias]
push-fwl = push --force-with-lease
你会在哪里使用别名 -> git push-fwl
当然,您可以随意命名push-fwl
。
至于文档,我认为此特定选项 而不是 具有 shorthand 的原因是因为其用法的复杂性。请记住,调用 --force-with-lease
.
的方法有很多种
摘自文档:
--[no-]force-with-lease, --force-with-lease=<refname>, --force-with-lease=<refname>:<expect>
这意味着它是 per-usage 我们希望如何使用此选项的基础。我假设维护者无法知道所有这些选项中的哪一个会最受欢迎,以便为它制作 shorthand。
更不用说 --force
是一个更广为人知、更常用的选项,因此有一个 shorthand 是有道理的。
文档继续进一步告诉我们如何针对所有这些选项进入不同的情况:
--force-with-lease alone, without specifying the details, will protect all remote refs that are going to be updated by requiring their current value to be the same as the remote-tracking branch we have for them.
--force-with-lease=<refname>, without specifying the expected value, will protect the named ref (alone), if it is going to be updated, by requiring its current value to be the same as the remote-tracking branch we have
for it.
--force-with-lease=<refname>:<expect> will protect the named ref (alone), if it is going to be updated, by requiring its current value to be the same as the specified value (which is allowed to be different
from the remote-tracking branch we have for the refname, or we do not even have to have such a remote-tracking branch when this form is used). If is the empty string, then the named ref must not already exist.
Note that all forms other than --force-with-lease=<refname>:<expect> that specifies the expected current value of the ref explicitly are still experimental and their semantics may change as we gain experience with this
feature.
鉴于您可以创建别名,我认为 git 的维护者没有充分的理由为相对晦涩的命令选项提供 shorthand。
在大多数情况下,我已经开始使用 git push --force-with-lease
而不是 --force
来进行额外的分支保护:
- git push --force-with-lease vs. --force
我什至可以尝试将此选项设置为默认选项,如下所述:
虽然使用 --force-with-lease
的主要烦恼是输入该标志的笨拙的措辞和冗长的语法。
Git 的 --force
和 -f
标志更短且更易于键入,但不提供额外的安全性。
有没有--force-with-lease
的简写形式,比如--fwl
?
- 如果没有,是否有未添加的原因?一个更方便的标志似乎会增加对更安全功能的采用。 git 的创建者讨论过这个问题吗?
如果默认情况下不存在这样的标志,我如何在自己的机器上创建这样的标志或别名?
该选项没有 shorthand。要 make a global alias,只需将此添加到 ~/.gitconfig
[alias]
push-fwl = push --force-with-lease
你会在哪里使用别名 -> git push-fwl
当然,您可以随意命名push-fwl
。
至于文档,我认为此特定选项 而不是 具有 shorthand 的原因是因为其用法的复杂性。请记住,调用 --force-with-lease
.
摘自文档:
--[no-]force-with-lease, --force-with-lease=<refname>, --force-with-lease=<refname>:<expect>
这意味着它是 per-usage 我们希望如何使用此选项的基础。我假设维护者无法知道所有这些选项中的哪一个会最受欢迎,以便为它制作 shorthand。
更不用说 --force
是一个更广为人知、更常用的选项,因此有一个 shorthand 是有道理的。
文档继续进一步告诉我们如何针对所有这些选项进入不同的情况:
--force-with-lease alone, without specifying the details, will protect all remote refs that are going to be updated by requiring their current value to be the same as the remote-tracking branch we have for them.
--force-with-lease=<refname>, without specifying the expected value, will protect the named ref (alone), if it is going to be updated, by requiring its current value to be the same as the remote-tracking branch we have for it.
--force-with-lease=<refname>:<expect> will protect the named ref (alone), if it is going to be updated, by requiring its current value to be the same as the specified value (which is allowed to be different from the remote-tracking branch we have for the refname, or we do not even have to have such a remote-tracking branch when this form is used). If is the empty string, then the named ref must not already exist.
Note that all forms other than --force-with-lease=<refname>:<expect> that specifies the expected current value of the ref explicitly are still experimental and their semantics may change as we gain experience with this feature.
鉴于您可以创建别名,我认为 git 的维护者没有充分的理由为相对晦涩的命令选项提供 shorthand。