If you have mutliple people using the same computer, or different user accounts for different repos it can be rather frustrating trying to figure out how to switch accounts if your on OSX and find your not being prompted for your login info because it's been cached.
That's all thanks to the helper utility for git which caches your login info (encrypted) in the OSX keychain.
To view the current credentials cached use the command
git credential-osxkeychain get followed by pressing enter twice.
if you press enter only once you will invoke the command but it will apear to hang, if you press enter a second time you will be prompted by a dialog box to confirm access to your keychain and then the information will be returned in terminal
And if you want to clear it so your prompted to login again you can clear it like this:
git credential-osxkeychain erase
But that's stupid. I don't want to have to do all this everytime I need to switch accounts.. There is a better solution.
If you would like to prevent this issue in the future you can configure the git helper tool for osx-keychain to store your login credentials associated with the entire path of the repository rather than just the domain which is the default.
In terminal enter the command
git config --global --edit
This will open a configuration file. If you haven't already, you may want to set your default editor so the file opens in your preferred application.. For example, to set Sublime Text as your default editor:
git config --global core.editor "subl -n -w"
With the config file opened, search for
useHttpPath (or define it if it doesn't exist). And set it's value to
true. It should look like this:
helper = osxkeychain
useHttpPath = true
This will instruct git (as well as github) that any credentials used to login should only be associated with the full repository path that was queried, not for the entire domain (in the case of github) all repositories on Github.com..
So now you can be logged into your repository, and your boyfriend can be logged into his repository and there will be no conflicts between your logins.