Created
June 5, 2024 06:41
-
-
Save jobwat/a351c51131ecb6b40e37fdcece56a076 to your computer and use it in GitHub Desktop.
git alias to update current repository password in osxkeychain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
[alias] | |
# ... | |
echo-remote-proto-and-host = "!f(){ REMOTE=origin; git remote -v | grep $REMOTE | head -n1 | sed -E \"s/^$REMOTE\\t+([a-z]+):\\/\\/([^\\/]+).*/protocol=\\1\\nhost=\\2/\";};f" | |
clear-credentials = "!f(){ git echo-remote-proto-and-host | git credential-osxkeychain erase ;};f" | |
get-credentials = "!f(){ git echo-remote-proto-and-host | git credential-osxkeychain get ;};f" | |
update-password = "!f(){ (git echo-remote-proto-and-host; git get-credentials) | sed \"s/password=.*/password=$1/\" | git credential-osxkeychain store ;};f" | |
# Usage: | |
#. Copy your new password in clipboard | |
# git update-password $(pbpaste) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment