Forced clicking on a new head when all changes have already been pulled

Is it possible to forcefully create a new remote head when pressed?

Suppose I made some local commits on the default branch, then pulled out and merged from the remote.

Now I would like to push my commits to remotely create a new chapter and bookmark, but keep the existing remote head and tip - that is. my colleagues should not get my changes while doing hg fetch .

Basically it should be a short-lived branch (and therefore an unnamed branch) for backup and code verification purposes by others, before completely merging with the "main" head of the default branch.

I tried --new-branch , but that didnโ€™t help - no new head was created, and the remote prompt moved to my head.

+4
source share
3 answers

You can use the --force option to force a new head.

The --new-branch used for a named branch, in your case we are talking about anonymous branching.

The reason the "tooltip moves" is because you merged a recently changed set of changes. By doing this, you cannot do what you want.

You just need to pull the new changes from the remote, and force everything to push without merging, this will create a new head (called an anonymous branch), which can later be merged with the default branch by you or someone else after reviewing the code.

You can also use the second repository to make changes, but this is a completely different workflow.

+1
source

You cannot save the tip when pressed: this is a pseudo-tag that always points to the latest set of changes in the repository. The concept of tip deprecated in Mercurial because tip can change the value more or less randomly depending on the order of clicks - as you saw.

The only way to create a new head is to create it :-) By this, I mean that you need two heads - one with your changes and one with the main code that you want colleges to pull and merge with. If only one head (the one that you got after running hg merge ) cannot signal colleges that they should not use it.

best used to use a separate repository on the server. Go to your repository management software and create a fork for your changes. Then click on it and inform the colleges about it. They will break out of your clone and consider the changes. If they like them, they can merge with the main code and click on the normal repo. If they donโ€™t like the changes, they can throw away their local clone, take away the changes, or maybe just drop the traction.

+1
source

My solution to this problem is to use the previous revision to start the bookmark, if it isnโ€™t there or you just donโ€™t want to, you can make a fictitious commit (for example, a small change in the README file, etc.) and bookmarks before that.

I think hg bookmarks need a lot of tweaking before they look like git branches, but the process I'm describing is largely explained in Mercury bookmarks start .

For example, if you are currently in edition 250.

 echo >>README hg ci -m "enabling bookmark branch_xyz" hg book my-tip # optional but nice to have hg book -r 250 branch_xyz hg up branch_xyz # hack ... hack hack hg ci -m "awesome feature xyz (in progress)" hg push -fB branch_xyz 

Now this bookmark lives on the server, while others work with it ... but it can be easily trimmed later

+1
source

Source: https://habr.com/ru/post/1396242/


All Articles