I started using SourceTree a few days ago to manage Mercurial repositories with my Mac. Now I ran into the problem when pushing to my remote repository creates a new head on a new branch and I would like to force it.
However, I am not able to find any specific option in SourceTree which allows me to set the force option for a push. Is it just my inability to find it or is there no possibility to set it?
Thanks in advance
Michael
In SourceTree 3 you can allow it in the advanced tab:
SourceTree is finally going to add force push:
https://jira.atlassian.com/browse/SRCTREE-1156
Reason:
https://answers.atlassian.com/questions/54469/how-do-i-perform-a-forced-push-push-f-from-sourcetree
Edit:
It is now added in SourceTree, but you need to turn the option on in the settings.
You can show it on Preferences -> Advanced -> Allow force push
Then force push option would be available.
In SourceTree version 2.5.5.0 there is an option for that.
Make sure you have enabled in options:
[Menu] Tools -> Options -> [Tab] Git -> [Section] Enable Force Push
After that, you can force push it using push button in toolbar:
And it works!
SourceTree (as of ver. 1.4.2) issues a hg push --new-branch as needed, so if you create a new branch (as opposed to having two heads on one branch), you just do a regular push (Repository → Push). You can, optionally, specify a branch you want to push if you have outgoing changesets on several branches.
I wasn't able to find a way to do a hg push --force proper via the SourceTree dialogs. I agree with #Ry4an that this option is more dangerous than useful. I've never done a force push since --new-branch was introduced, and never needed it to combine unrelated repositories or push a two-headed branch (a force pull is much safer).
I conclude that on a rare occasion when a force push is needed, opening Terminal won't hurt. If you disagree, please share your workflow in comments.
it's now under Sourcetree -> Preferences -> Advanced -> Allow force push
Related
I just found out that we're not supposed to create named branches in our local Mercurial repos, because they get carried along and pushed to the upstream repo, where they live forever.
Unfortunately, I already have multiple feature branches in my local repo, which I was all set to merge to default and push up to the main repo. So, what I need to do is keep the work in these branches (somehow) but remove the named branches.
Is there a way to do this, short of a lot of horrible manual revert/cut/paste?
Using TortoiseHg:
(Ensure rebase extension is enabled in File -> Settings -> Extensions)
Update to parent of the first change set of the named branch.
Right click on the first change set of the nambed branch and click rebase.
Ensure "Keep orignal branch names (--keepbranches)" is NOT checked.
Ensure "Rebase entire source branch (-b/--base)" is checked.
Click rebase.
Another approach would be to use the hg convert command (a standard extension) and the branchmap option.
For a private repository or at least one with changesets which have not been published this would work fine, even though like a rebase it would modify history.
An advantage as opposed to using rebase is that it could be used to deal with multiple branches (named or unnamed) all at once. That might be quicker / easier if there was a lot of things to move around.
A secondary plus is that since convert will create a NEW repository there is no risk to the original if something doesn't work as expected. (Of course when using rebase you could make a backup first which I think is a reasonable precaution.)
I couldn't find a relevant thread anywhere, but possibly this important task has to be asked about many times before..
I have a central repository, from which I have cloned to form a local repo. Now I made several changes and commits to local repository. Now I need to push/commit the final version to central repo. How do I do this?
I'm using TortoiseHg as the client.
When I right click, in the context menu of tortoise, I can see Update as well as Synchronize. I am not sure if either of these are meant for my job. If I select Update I see an Update to combobox where it has default, tip etc. Not sure what are these. When I select Synchronize, all I see are (confusing) options that deal with remote repository. Or does remote repo mean central/main server repo?
Thanks.
You can have more than one (any) amount of remote repositories.
Mercurial is DVCS (D - Distributed). Central/Main is just conventional repository, which all teammates use for intermediate code-storage (by agreement and workflow)
Synchronize toolbar (most right in toolbars, when enabled) is your best friend
1 in screenshot is for actions-button for data-transfer (read hints for buttons /and THG help/)
2 is section of defined remotes (in your case, after clone, you'll have only "default" alias), for which selected (by button) action will be performed
PS: from CLI it's a lot faster:
cd REPO_DIR
hg push
Maybe this is a bit late but.....
if you are familar with subversion, think of (mercurial) update as a (subversion) switch...and (mercurial) synchronize as (subversion) checkout and/or commit.
This question is the same as: TortoiseHg: Push Branch, except it is for TortoiseHg 2.0. The old way no longer works. The options are not even there.
Here is the issue: As I work on different bugs, I create different branches for each. How can I push just one branch using TortoiseHg 2.0?
When I go into sync view, and push - I believe it tries to push all my local branches, and ends up aborting - since multiple heads would be created.
The feature exists in TortoiseHg v2, but the interface changed. In the Sync tab, there is the following menu:
Enable the "Target" checkbox
Select the branch you want to push
Push as you normally would
I am trying to grok Mercurial and hope I am just getting confused here!
I have a repository ('main') that I have cloned ('clone'), , both on my own machine. Both were completely in sync with each other.
I decided to play with named branches so the next time I committed on my 'clone' I did it under a branch name of 'case1212' and while it seems to have dealt with the commit properly on my clone, I cannot push these changes back to 'main'. The error given is:
abort: push creates new remote branch 'case1212'!
...and it suggests that I might need to merge first? What am I supposed to merge on that 'clone' repository? When I try to pull from 'main', there are no changes.
I'm pretty sure I actually would want it to create a remote branch in my 'main' repository so people who update from it can see that branch.
Mercurial's default behavior prevents you from creating remote branches. If you want to do this, you need to force-push.
Synchronize menu in the window you show, there is an option for force push.
Tortoise now has an option Push new branch that may be safer than Force pull or push. The command line tool has a flag --new-branch.
Update: The new tortoise interface makes it a bit harder to find. Switch to the Synchronise view, then click options and select allow push of a new branch.
It's warning you that your push would create new remote heads (and in this case branches). If you're okay with that, and it sounds like you are, you can push with push -f.
This check is in there so that if you wanted that case1212 branch to not go back to the main server you could do hg push -r default and then you'd not see this warning and not send case1212.
Once you've done this for case1212 you won't see the warning again since case1212 will already be there.
Newer versions of mercurial make that warning a little less scary sounding in the case where the new head is a new branch.
I downloaded TortoiseHg 1.0 for evaluation. For the life of me I can't figure out how to make a branch. It seems to understand branches (e.g. in its repository browser) but I just can't seem to find a way to make a branch. This seems like such a fundamental capability since out of the often touted benefits of DVC is the lightweight branching.
I Googled around and couldn't find much discussion of this topic (at least for recent versions) so I have to assume I'm missing something, right?
Update: So I flagged Chad Birch's answer below to answer the "new branch" issue. As he correctly points out, you do a commit and then click on the branch button to bring up the branch maintenance dialog which is where you create new branches. I kind of wish they had given us a context menu option for this. Once you've branched, the next natural question is how to merge and this is also not obvious. It turns out that option is buried in the repository explorer. You need to select the head of another branch, right-click and then select "Merge with...".
As shown in the docs, all you should need to do is just click on the branch: default button near the top of the commit dialog, and change to a new branch name.
To start new branch with TortoiseHg press Commit... then, above Commit message press Branch, then "Open new named branch: "
Just wanted to add that in order to push new branch to remote repository there is a checkbox on the Synchronize tab under Options of "Allow push of a new branch" - you have to remember to turn it off again right afterwards.
Most of the time in mercurial, you clone the repository to make a branch.
You can then merge the separate repositories once you made your edits and commits.
This might sound like it would take up a lot of disk space but on most operating systems, mercurial will make hardlinks instead of copying the files. Anyway, disk space is normally cheap, and because it's local it's rather fast.
If you think about it, every "checkout" (in svn terminology) or "clone" (in mercurial terminology) is really a branch that will probably be merged back so it makes lots of sense that clones are the common way of making branches.
Before commiting, click on Branch button (see image), Then select a branch or create a new one (by typing where you select the branches).
See the image here