push to remote repo after local hard reset



when I do a local hard reset to some previous commit and try to push to remote repo I get a "remote repo is ahead" (along those lines) error message.


Found this related thread at stackoverflow


What I currently do from command line is what's mentioned there as answer:


git fetch origin
git reset --hard origin/master
git clean -f


Can I also do this directly from within SourceTree ?

I see a button for fetching, is functionality for reset and clean also build in ?


Just curious, as this would make the process a little quicker than switching to command line.



1 answer

That's an odd series of commands.  You should be able to just do a 

push -f

I don't think you can do it within SourceTree, though - at least, not without setting up a Custom Action, which I haven't played with much

Thanks, I'll try next time I need to do this and report back.

Talking of force-push, there actually is a "Force" tickbox in SourceTree's Push dialog, but it's always grayed out here. Any idea why ?




Suggest an answer

Log in or Sign up to answer
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

992 views 2 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you