views:

34

answers:

1

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.

+4  A: 

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
Niall C.