Michael Rose
Michael Rose

Reputation: 7820

Force a push with SourceTree

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

Upvotes: 54

Views: 41574

Answers (6)

Pengguna
Pengguna

Reputation: 4941

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

Upvotes: 21

oskarko
oskarko

Reputation: 4168

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

Upvotes: 0

Martin
Martin

Reputation: 4765

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

enter image description here

Upvotes: 41

Kostiantyn Korniyenko
Kostiantyn Korniyenko

Reputation: 649

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!

Upvotes: 7

Daniel Ryan
Daniel Ryan

Reputation: 7102

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.

Upvotes: 24

Helgi
Helgi

Reputation: 5436

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.

Upvotes: 2

Related Questions