gpt4 book ai didi

git - 定期 git fetch 的副作用

转载 作者:太空狗 更新时间:2023-10-29 14:03:30 28 4
gpt4 key购买 nike

假设我有这样的代码:

git fetch &&  git diff origin origin/master --quiet || echo "untracked"

我希望它定期运行。比方说,每秒一次,或每五秒一次,依此类推。

如果此代码输出“untracked”,或者换句话说,如果远程有更新,我将运行 git pull 来更新本地代码。

问题是:做这样的事情不好吗?我的意思是,我知道这将是对远程服务器的持续请求。但是,不好吗?除此之外,还有其他副作用吗?非常感谢。

最佳答案

如果执行得太频繁,除了会使其他命令失败之外,常规提取的主要缺点是 push --force-with-lease .

我在“ push --force-with-lease by default”中记录了同样多的内容

--force-with-lease or --force-with-lease=<refname> interacts very badly with anything that implicitly runs git fetch on the remote to be pushed to in the background, e.g. git fetch origin on your repository in a cronjob.

The protection it offers over --force is ensuring that subsequent changes your work wasn't based on aren't clobbered, but this is trivially defeated if some background process is updating refs in the background.

关于git - 定期 git fetch 的副作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49948894/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com