Flush your local Git password on SourceTree for Mac

Atlassian's SourceTree is the best Git UI available on Mac. Yes even better than GitKracken. And it's actually free, as in free, not freemium (and also not freedom).

The Problem

You work at a company that uses git (as opposed to Mercurial), but the tyrannical Infosec team refuses to allow key based authentication.

Let's be absolutely clear, this is an unwarranted power grab. The only logical solution here is to hop on the most populated Slack channel your organization, and freak the hell out. Eventually escalate to HR and then slandering your own company on a public forum like Twitter or Reddit.

Like who do these people think they are. Password based auth suuuucks. You know the Nazis weren't allowed to use key based auth either. Everybody on StackOverflow does key based auth and it's soooo 1337 so whatever Infosec they're so dumb.

Or maybe your Git provider doesn't offer key based SSO. In which case you're still right, maybe purchase some Google ads for your slander campaign.

You're stuck with HTTP based auth

So you're working at a company that uses git, and you have to use password based auth. Simply enter your creds into SourceTree the first time it asks, and click "remember me".

Life is good.

Until Infosec screws you again.

Now they're forcing you to rotate your password. And SourceTree can't seem to grok this. So basically you have to throw out your sticker covered laptop and start over. If only there was a way to un-cache-erize these credentials you could save yourself the new laptop.

The Solution

Well actually it's very easy. Just find your password cache and delete it.

Mine is here: /Users/pvarney/Library/Application\ Support/SourceTree/[email protected]

Tl;Dr

I created a one liner script that I leave in my home directory.

#!/bin/bash

rm /Users/pvarney/Library/Application\ Support/SourceTree/[email protected]

So when the time comes I just

./reset-sourcetree-pw.sh

And the next time I pull or push in SourceTree it prompts for creds and I forget about the whole ordeal for the next few months.

More info

The above answer is buried in the comments in here https://community.atlassian.com/t5/Sourcetree-questions/How-to-update-HTTP-S-credentials-in-sourcetree/qaq-p/297564