I have a code base that some of the developers work on via RDP and use the IDE that is on the remote machine. I would like to know if there is a way to force them to enter their own name when committing changes. Right now Git is defaulting to my name which is incredibly annoying since I am not the one making the changes.
Also when something is pushed to GitHub, it does ask for user name/password, but I can’t seem to find any indication of that user’s information in the commit list.
** EDIT ** FYI **
My original intention was to force a user signed in under a shared account (unavoidable) to enter their user.name and user.email credentials each time the commit command was run. In order to accomplish this, I tried to use a login script for Windows that would essentially clear and set these values each time a new person logged in;
@echo off
cls
REM * Notify user
echo Clearing Git user information...
REM * Go to Git directory
cd C:\"Program Files (x86)"\Git\bin\
REM * Clear user information
git config --global --remove-section user
REM * Get the user's name
set /p name= Please enter your first name:
REM * Get user email
set /p email= Please enter your email:
REM * Set Git configuration
git config --global user.name "%name%"
git config --global user.email "%email%"
::REM * exit
exit
But I could not get it to work consistently via RDP which is its main use case.
This lead me to try to use the pre-commit hook for Git which I used essentially the same script modified for Bash. This also didn’t work, because Git assigns the “author” before calling the hook.
In other words, if the user configuration was name = jim and email = bob@test.com the Git log would have the author as jim<bob@test.com> and then the next commit would have the entered information.
#!/bin/sh
#
exec < /dev/tty
# Notify user
echo "Clearing Git user information..."
# Go to Git directory
#cd c:\"Program Files (x86)"\Git\bin\
# Clear user information
git config --global --remove-section user
# Get the user's name
echo "Please enter your first name: "
read name
# Get user email
echo "Please enter your email: "
read email
echo name: $name email: $email
read -n 1
# Set Git configuration
git config --global user.email $email
git config --global user.name $name
#exit
You look to be in a dirty development setup, so something as dirty:
Make a logon script that erases Git’s user name and email, the developers will have to enter it at each time they connect to the machine.
Git will then ask for name/email on the first run if it’s not configured.
Of course, creating Windows user sessions and having per-user Git configuration is better 🙂