Skip to content

Instantly share code, notes, and snippets.

@cryptorick
Created May 2, 2023 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cryptorick/527cf36cb0f1027afaf9e1df3ab579a8 to your computer and use it in GitHub Desktop.
Save cryptorick/527cf36cb0f1027afaf9e1df3ab579a8 to your computer and use it in GitHub Desktop.
Impersonate people in git
;; Add this, if you want, to the bottom of your $HOME/.gitconfig.
;; Impersonate people: add personages (like the 3 below here); then say
;; $ git impersonate bob
;; Now, git thinks you are Bob (locally of course). This is good for helping
;; your team do git surgery on a branch (and retain the credit for the original
;; person's work). Don't forget to set yourself back (unmask) when you are done.
;; $ git impersonate me
;;
[user-me]
name = Joe Blow
email = jblow@geemail.com
[user-rick]
name = Rick Sharky
email = slickrick@vegas.fun
[user-bob]
name = Robert Young
email = bobby@example.com
; Template for adding a user: copy the following 3 lines above, uncomment and fill in.
; [user-]
; name =
; email =
[alias]
whoami = "!f() { git config user.name && git config user.email; }; f"
impersonate = "!f() { git config user.name \"$(git config user-$1.name)\" && git config user.email \"$(git config user-$1.email)\" && git whoami; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment