Skip to content

Instantly share code, notes, and snippets.

@kelvinj
Last active August 29, 2015 14:03
Show Gist options
  • Save kelvinj/0c552af8eff8f1d931b7 to your computer and use it in GitHub Desktop.
Save kelvinj/0c552af8eff8f1d931b7 to your computer and use it in GitHub Desktop.
Update passwords of git repos using an HTTP remote following a change of password on the server
find . -path "*/.git/config" -exec sed -i.bak-$YYYYMMDD "s/$OLDPASSWORD/$NEWPASSWORD/g" '{}' \; -exec grep -l "$NEWPASSWORD" '{}' \;

The passwords will be stored in .git/config, so what we need to do is:

  1. find all files in the current directory that match '*/.git/config',
  2. swap out the old password for the new…
  3. making a backup of the original,
  4. and the display the names of the files that have been changed for double-checking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment