53

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

nwellnhof
  • 32,319
  • 7
  • 89
  • 113
Michael Rose
  • 7,770
  • 3
  • 22
  • 26
  • 3
    It's not your answers (never used sourcetree), but from the command line it's preferable to use `hg push --new-branch` instead of `hg push --force`. The reason being `--force` can override all sorts of "Are you sure?!" messages including (a) new head on existing branch and more importantly (b) completely unrelated repositories. Using `--new-branch` still stops/warns you in those other two cases. – Ry4an Brase Feb 07 '12 at 21:10
  • Try Fork instead! – Display Name Jul 12 '19 at 07:11

6 Answers6

38

In SourceTree 3 you can allow it in the advanced tab:

enter image description here

Display Name
  • 4,502
  • 2
  • 47
  • 63
24

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.

Daniel Ryan
  • 6,976
  • 5
  • 45
  • 62
  • 1
    note that this is only available in 1.6, which is just out in beta since last week: http://blog.sourcetreeapp.com/2013/03/28/sourcetree-for-mac-1-6-beta/ – Alex Dupuy Apr 05 '13 at 12:53
  • Are you sure it's in the first beta? I couldn't see the option and the issue in Jira still shows "in progress". – Daniel Ryan Apr 07 '13 at 22:42
  • 1
    Jira status shows as Closed for me, but the feature as described in the ticket indeed does not appear to be implemented (yet?) in the first beta. Hopefully in the second one? The interactive rebase (for Git) makes the beta worth downloading even without force push (at least for me). – Alex Dupuy Apr 09 '13 at 06:19
  • Yeah it's closed now, hopefully it's in the 2nd beta. The first beta is going well for me too :) – Daniel Ryan Apr 10 '13 at 03:43
  • When I said the above comment originally, I believe I missed the option in settings to turn it on. But been using force push for some time now and it is working great. – Daniel Ryan Jun 20 '14 at 02:08
17

You can show it on Settings -> Advanced -> Allow force push

enter image description here

Then force push option would be available.

enter image description here

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
Pengguna
  • 4,636
  • 1
  • 27
  • 32
7

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

enter image description here

After that, you can force push it using push button in toolbar:

enter image description here

And it works!

2

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 (RepositoryPush). 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.

Helgi
  • 5,428
  • 1
  • 31
  • 48
  • I think the `--new-branch` option is enough now, since we changed the workflow a little bit (as you indirectly suggested ;). Thanks for your help! – Michael Rose May 22 '12 at 07:02
  • 1
    I'm not sure for Mercurial, but for Git, a rebase workflow is quite common. Our entire company use SourceTree for everything, but instead of pulling/merging we instead rebase our current branch on top of the branch we wish to merge onto. Rebasing using SourceTree is all well and good, but it's useless when we can't then force push our changes up onto our remote! We then have to rip open terminal upon every "merge". Why disable dangerous features, rather than expose them with lots of warnings? – Tim Aug 07 '12 at 01:00
  • @Tim: I believe that the force push in Git differs from the force push in Mercurial. If you have to do a force push after rebase in Mercurial, you won't probably like the result (two copies of the same branch in the remote repo). As for Git, I can't say. – Helgi Aug 07 '12 at 17:44
  • 1
    @Helgi Ah I see. Well at least they're adding it in now. I got a reply from the developer and he'll be putting it in in 1.6 :) – Tim Aug 08 '12 at 05:10
0

it's now under Sourcetree -> Preferences -> Advanced -> Allow force push

oskarko
  • 3,382
  • 1
  • 26
  • 26