hg: how do I push newly created branch back into central repository?
It depends on the version of Mercurial that you're using. The command used to be hg push -f ...
or hg push --force ...
to force the creation of a new branch in the remote repository (which is usually OK).
However, using -f
also allows you to create new heads in the remote repository (usually not OK), so current versions of Mercurial (1.6 and above) have a --new-branch
option to hg push
that allows you to create a branch, but not create a new head, so the command is:
hg push --new-branch
You can also limit pushes to just the branch that you're working on with the -b
flag, so:
hg push --new-branch -b v1
Alex Khvatov
Updated on July 09, 2022Comments
-
Alex Khvatov almost 2 years
I cloned the centeral repository via
hg clone my_project my_project_1
then after switching to a newly created repo I marked as a new branch
hg branch v1
While inside the new clone I issued
hg ci -m "branch created"
but when I tried to push the changes back to the original repository I cloned from I got this error:
abort: push creates new remote branches: v1!
How do I push the branch into the original repository? Am I doing the right thing by trying to push the branch into the original repo? I just want to have a centralized repository which would contain branches and from which I would be able to check out branches. What's the best way to deal with this problem? Thank you.
-
NoBugs over 10 yearsIt looks like unlike git, you have to create a commit to be able to push:
hg ci -m "Creating a branch"
-
John Slegers over 10 years@NoBugs In the question, the OP said that they already did that.