The challenge
I come across a common problem when working with Git. I am a consultant and working on different projects. This means that I do have multiple Git repository to commit to. All of them have some kind of user recognition in a web GUI. This means that the web scans the commit for the user's name and email address to check against its users and find the correct one. This will resolve, for example, into a profile picture beside the commits. As, amongst others, Atlassian Stash does.There are multiple solution to set your name and email depending on the client you use but it is cumbersome at best.
The solution
There is a very simple and easy solution. As Git allows settings per repository, you can define a name and email for each of them. After navigating to the repository you want to configure, write:
git config --local user.email "your@email.com"
git config --local user.name "Your Name"
You may also want to set a "default" settings for new repositories. To do so, you can use the --global instead of --local
git config --global user.email "your@email.com"
git config --global user.name "Your Name"
This will set these settings for your user. You can even go further and set it with the --system. This will be active for all users on this computer
No comments:
Post a Comment