安全推力程序? [英] Safe force push procedure?
问题描述
我听说用力推动(git push -f
)是一种危险的做法,应尽可能避免.话虽如此,在一个小型团队之间共享私人回购的情况下,这样做的安全程序是什么?我想这会是这样的:
I hear that force pushing (git push -f
) is a dangerous practice to be avoided if possible. That being said, what would be a safe procedure for doing so in the case of a private repo shared among a small team? I imagine it would be something like this:
- 我要求团队成员在完成之前不要推动.
- 我拿来.
- 我根据需要更新分支的历史记录(修改,重新设置等).
- 我强迫推.
- 我告诉他们我已经完成.
- 他们用___来获取新历史并将其与代码集成在一起,而不会丢失任何内容.
有人可以完成或取消此过程并提供更好的过程吗?我正在寻找最简单的安全程序.
Can someone complete this procedure or scrap it and offer a better one? I'm looking for the simplest safe procedure.
推荐答案
您可以执行git push --force-with-lease
仅当远程分支在远程中处于与您在本地看到的状态相同的状态时,它才会推送您的更改.
参见 https://git-scm. com/docs/git-push#git-push ---无强制租赁以获取更多详细信息.
You can do git push --force-with-lease
It will push your changes only when the remote branch is in the same state in the remote as you can see it locally.
See https://git-scm.com/docs/git-push#git-push---no-force-with-lease for more details.
这篇关于安全推力程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!