默认情况下推--force-with-lease [英] push --force-with-lease by default

查看:308
本文介绍了默认情况下推--force-with-lease的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚了解到 git push --force-with-lease 。这非常棒。但是,当然,我并不经常使用武力,所以我担心我下次需要时可能会忘记这个漂亮的功能。



有没有办法配置git,所以 git push -f 会自动使用 - force-with-lease ,除非我有意用覆盖它 - 没有强制与租赁



(我无法想象有没有想要)

解决方案

AFAIK没有配置可用于告诉git始终使用 force-with-lease 而不是 force 。这似乎是一个功能请求的好例子;如果你没有问题可以深入到git代码库中,你可以自己实现它并提交它进行审查。



编辑它在2018年2月仍然如此。



在此之前,我看到的唯一选择是,经常创建一个 alias 即可达到此目的。



创建别名



创建一个别名可以使用 git config --global alias。< alias-name>

  git config  -   -global alias.pushfpush --force-with-lease

这将创建一个条目您的全局 .gitconfig 文件(您通常可以在主目录中找到)。在此之后,您可以简单地使用 git pushf 来使用 force-with-lease

让你的手变脏



如果你想自己实现这个功能,但不确定从哪里开始,那么首先应该看看 文档在git仓库中的目录。您可以在这里找到 编码指南 和有关如何提交补丁 的信息。



您可以在官方社区页面找到所有这些链接和更多内容


I just learned about git push --force-with-lease. It's pretty awesome. But, of course, I don't use force that often, and so I'm worried that I might forget about this nifty feature the next time I need it.

Is there a way to configure git so git push -f will automatically use --force-with-lease unless I intentionally override it with --no-force-with-lease?

(I can't imagine ever wanting to use force without lease!)

解决方案

AFAIK there is no configuration available to tell git to always use force-with-lease instead of force. This seems to be a good example for a feature request; if you have no problem to dive into the git code base you could implement it yourself and submit it for review.

EDIT As it stands, this is still true in February 2018.

Until then the only option I see is, as so often, to create an alias which serves this purpose.

Create an alias

To create an alias one would use git config --global alias.<alias-name> <command>, in our case I would suggest something similar to this.

git config --global alias.pushf "push --force-with-lease"

This will create an entry in your global .gitconfig file (which you can usually find in your home directory). After this you can simply use git pushf to force-with-lease.

Get your hands dirty

If you want to implement the feature yourself but aren't sure where to start, you should at first take a look at the documentation directory in the git repository. Here you can find the coding guidelines and information on how to submit patches.

You can find all these links and more on the official community page.

这篇关于默认情况下推--force-with-lease的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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