何时在存储库中创建一个新的头? [英] When does a new head is created in a repository?

查看:75
本文介绍了何时在存储库中创建一个新的头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我假设这是一个很奇怪的问题,但是我不确定何时在存储库中创建一个新的头,例如在这个问题中:

I'm assuming this is kind of weird question, but I am not sure when exactly a new head is created to a repository, for example in this question :

说明在任何引用的存储库中哪些行导致头数更改

Explain which line(s) cause the number of heads to change in any of the referenced repositories

1:/home/user> hg clone http://remoteserver/mainrepository clone1

1: /home/user> hg clone http://remoteserver/mainrepository clone1

2:/home/user> hg clone http://remoteserver/mainrepository clone2

2: /home/user> hg clone http://remoteserver/mainrepository clone2

3:/home/user> cd clone1

3: /home/user> cd clone1

4:/home/user/clone1> echo one> a.txt#创建一个包含一个"的新文件"a.txt"

4: /home/user/clone1> echo one > a.txt # Create a new file "a.txt" containing "one"

5:/home/user/clone1>回显两个> b.txt#创建一个包含两个"的新文件"b.txt"

5: /home/user/clone1> echo two > b.txt # Create a new file "b.txt" containing "two"

6:/home/user/clone1>回显三> c.txt#创建一个包含三个"的新文件"c.txt"

6: /home/user/clone1> echo three > c.txt # Create a new file "c.txt" containing "three"

7:/home/user/clone1> hg添加a.txt b.txt c.txt

7: /home/user/clone1> hg add a.txt b.txt c.txt

8:/home/user/clone1> hg commit -m添加的文件"

8: /home/user/clone1> hg commit -m "Added files"

9:/home/user/clone1> cd ../clone2

9: /home/user/clone1> cd ../clone2

10:/home/user/clone2> echo none> a.txt#创建一个包含"none"的新文件"a.txt"

10: /home/user/clone2> echo none > a.txt # Create a new file "a.txt" containing "none"

11:/home/user/clone2> echo none> b.txt#创建一个包含"none"的新文件"b.txt"

11: /home/user/clone2> echo none > b.txt # Create a new file "b.txt" containing "none"

12:/home/user/clone2> echo none> c.txt#创建一个包含"none"的新文件"b.txt"

12: /home/user/clone2> echo none > c.txt # Create a new file "b.txt" containing "none"

13:/home/user/clone2> hg添加a.txt

13: /home/user/clone2> hg add a.txt

14:/home/user/clone2> hg commit -m一个文件"

14: /home/user/clone2> hg commit -m "one file"

15:/home/user/clone2> hg添加b.txt

15: /home/user/clone2> hg add b.txt

16:/home/user/clone2> hg commit -m另一个文件"

16: /home/user/clone2> hg commit -m "another file"

17:/home/user/clone2> hg pull ../clone1

17: /home/user/clone2> hg pull ../clone1

18:/home/user/clone2> hg添加c.txt

18: /home/user/clone2> hg add c.txt

19:/home/user/clone2> hg commit -m第三个文件"

19: /home/user/clone2> hg commit -m "a third file"

20:/home/user/clone2> hg push -f

20: /home/user/clone2> hg push -f

21:/home/user/clone2> cd ../clone1

21: /home/user/clone2> cd ../clone1

22:/home/user/clone1> hg push -f

22: /home/user/clone1> hg push -f

23:/home/user/clone1> hg pull

23: /home/user/clone1> hg pull

我不是在寻找这个问题的具体答案,只是一些可以帮助我了解它何时发生以及为什么发生的键.

I am not looking for a specific answer to this question, just some keys that will help me understand when does it happen and why.

提前谢谢!

推荐答案

可以通过三种方式创建新头像:

A new head can be created in three ways:

  • 需要在push命令上使用--force时,会在您要推送到的存储库上创建一个新的磁头.提示:不必使用--force(或等效的-f)时不要使用push
  • 当您提交到不是分支头的变更集时;因此,如果您承诺包含孩子的变更集.
  • 当您从存储库中提取资源时,该存储库将在本地已经有子代的变更集的顶部添加新变更集.
  • when you need to use --force on the push command, a new head is created on the repository you push to. Hint: Do never use --force (or its equivalent -f) with push when you do not have to
  • when you commit to a changeset which is not a branch head; thus if you commit to a changeset which has children.
  • when you pull from a repository which adds new changesets on top of a changeset where you locally have already children.

在您的情况下,第22步将为远程存储库引入一个新的头.步骤#20中的push --force不能帮助您看到它仅在#22中发生,因为您因此系统地使水银变暗,表明正在创建一个新的打印头.

In your case step #22 would introduce a new head to the remote repository. The push --force in step #20 is not helping you to see that it only happens in #22 as you thus systematically mute mercurials hints that a new head is being created.

合并不同的头(或重新设置基准,但除非在某些情况下(例如未发布存储库和阶段< public),否则不会传播)会减少头的数量.

The number of heads are reduced when you merge different heads (or rebase - but that does not propagate except under certain conditions like non-publishing repository and phase < public).

这篇关于何时在存储库中创建一个新的头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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