简体   繁体   English

强制创建Mercurial远程头(即分支)的坏主意?

[英]Bad idea to force creation of Mercurial remote heads (ie. branches)?

I am developing a centralized web application, and I have a centralized Mercurial repository. 我正在开发一个集中的Web应用程序,我有一个集中的Mercurial存储库。

Locally I created a branch in my repository 在本地我在我的存储库中创建了一个分支

hg branch my_branch

I then made some changes and committed. 然后,我做了一些改变并承诺。 Then when I try to push, I get 然后,当我试图推动时,我明白了

abort: push creates new remote branch 'my_branch'!
(did you forget to merge? use push -f to force)

I've just been using push -f. 我刚刚使用push -f。 Is this bad? 这不好吗? I WANT multiple branches in my central, remote repository, as I want to 1) back up my work and 2) allow other developers to develop with me on that branch. 我希望在我的中央远程存储库中有多个分支,因为我想1)备份我的工作,2)允许其他开发人员在我的分支上与我一起开发。

Is it bad or something to have branches in my remote repository or something? 在我的远程存储库中有分支或其他什么东西是坏的还是什么? Should I not be doing push -f (and if not, what should I do?)? 我不应该做推-f(如果没有,我该怎么办?)? Why does Joel say this in his tutorial: Joel为什么在他的教程中这样说:

替代文字
(source: grabby.info ) (来源: grabby.info

Occasionally I've made a change in a branch, pushed, switched to another branch, and changes I had made in that branch I switch to were mysteriously reverted to a previous version from several commits ago. 偶尔我在分支中进行了更改,推送,切换到另一个分支,我在切换到的那个分支中所做的更改被神秘地恢复到几个提交之前的先前版本。 Maybe this is a symptom of forcing a push? 也许这是迫使推动的症状?

My suspicion is that others with more time can answer better, but here is something related I found: 我怀疑有更多时间的人可以更好地回答,但这里有一些我发现的相关内容:

https://www.mercurial-scm.org/wiki/TipsAndTricks#Prevent_a_push_that_would_create_multiple_heads https://www.mercurial-scm.org/wiki/TipsAndTricks#Prevent_a_push_that_would_create_multiple_heads

It is related to a different option (specifically breaking push -f), but it mentions something along the lines of what you ask: 它与一个不同的选项(特别是破坏push -f)有关,但是它提到了你所要求的内容:

While a plain 'hg push' will warn you if you're going to create new heads, that is merely a warning on the client side intended to help/remind users that they may have forgotten to merge first. 虽然一个简单的“hg push”会警告你,如果你要创建新头,这只是客户端的一个警告,旨在帮助/提醒用户他们可能忘记了首先合并。

Assuming this is an accurate statement then you are perfectly safe to do so. 假设这是一个准确的陈述,那么你是完全安全的。

Note however that I have only basic knowledge in Mercurial so shouldn't be used as a source of complete truth :). 但请注意,我只有Mercurial的基本知识,所以不应该用作完整真理的来源:)。

No, it's not bad to force the push when you create a new branch. 不,在创建新分支时强制推送也不错。 The error/warning is issued because the new branch causes the repository to have two topological heads. 发出错误/警告是因为新分支导致存储库具有两个拓扑头。 That is, there are now two changesets without children: the tip of your default branch, and the tip of your new branch. 也就是说,现在有两个没有子项的变更集:默认分支的提示和新分支的提示。

With Mercurial 1.6 (to be released in two weeks time) you will be able to do 使用Mercurial 1.6(将在两周后发布),您将能够做到

hg push --new-branch

to allow the creation of new remote branches. 允许创建新的远程分支。 This is safer since --force disables all safety guards, whereas --new-branch only allows you to create a new branch. 这更安全,因为--force禁用所有安全防护,而--new-branch仅允许您创建新分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM