- Makes things a little bit faster if you were to commit as multiple users to a single repository
- User should have git installed on their machine
- Add the following bash script to the folder containing cloned repo. Recommended file name is 'cfup.sh':
#!/bin/bash
message=$1
user=$2
configure_commit_push() {
git config user.name "$1"
git config user.email "$2"
git add . && git commit -m "$message" && git push
}
# add more functions like below for additional users
talion() {
configure_commit_push "Talion" "[email protected]"
}
celebrimbor() {
configure_commit_push "Celebrimbor" "[email protected]"
}
shelob() {
configure_commit_push "Shelob" "[email protected]"
}
# add function names defining users to this array
functions=("talion" "celebrimbor" "shelob")
if [ -z "$user" ]; then
random_function=${functions[$RANDOM % ${#functions[@]}]}
$random_function
elif type "$user" >/dev/null 2>&1; then
$user
else
echo "Invalid user provided."
fi
- Replace functions user1,user2,user3 with functions calling configure_commit_push using the parameters of your users' configs. You can add any number of functions to suit the user count you wish. But remember to add those function names into functions array.
Refer this to learn more about how to run bash scripts in different OSs. Given commands are for unix and linux.
-
Commit and push as a random user from the pool (Replace cfup with your file name):
- sh cfup "chore: some commit message" - Commits and pushes as a random user from the pool
-
Commit and push as user shelob (Replace cfup with your file name):
- sh cfup "chore: some commit message" shelob - Commits and pushes as user shelob