Created
January 28, 2023 14:56
-
-
Save festival4799/cb0211c2f4439d962a8f730ce4eb14ba to your computer and use it in GitHub Desktop.
Multiple identities in gitconfig with alias
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
| #!/bin/bash | |
| # Set the different identities used in your global '~/.gitconfig' file | |
| git config --global user.gitlab.name "Your Name" | |
| git config --global user.gitlab.email "gitlab@example.com" | |
| git config --global user.github.name "Your Name" | |
| git config --global user.github.email "github@example.com" | |
| git config --global user.identity3.name "Your Name" | |
| git config --global user.identity3.email "identity3@example.com" | |
| # Create an alias to setup the identity | |
| git config --global alias.identity '! git config user.name "$(git config user.$1.name)"; git config user.email "$(git config user.$1.email)"; :' | |
| # Now, you can set your local identity with the comand below: | |
| git identity gitlab # Set the gitlab identoty in your local '.git/config' file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment