DEV Community

Tilwa Qendov
Tilwa Qendov

Posted on

git-commit-as: committing on a shared computer

I recently wrote a script to solve an issue I had committing on a shared computer. I'm sharing it with you because I think it's useful.

When I'm on a shared computer, I always forget to reconfigure my own name and email in git, so I end up committing under the name of the last person using the computer.

This is why I wrote git-commit-as, which is used as such:

git commit-as John -m "Committed by John"

Having previously configured a name and email for "John" in the git configuration file:

[users "John"]
    name = "John Doe"
    email = "john.doe@example.com"

You can get the script on GitHub. It's (probably) POSIX-compatible, which means it should work in sh, bash and zsh.

Top comments (0)