Erick T
Erick T

Reputation: 7429

Running scripts during git commit

Is it possible to call/start another process/command prior to git finishing the commit?

My co-workers and I share computers, and for any given commit, it could be one of a number of people doing the work. The problem is that it is a hassle to remember to set the git username prior to doing the commit, and so it never happens. What I would like is a way to have a prompt come up when "git commit" is called that would ask for the current user and then set the git user to that value. Setting up a commit script is one way to do this, but most people directly call git, so that wouldn't work.

Is this possible to do? Without forking git that is. :)

Thanks, Erick

Upvotes: 2

Views: 569

Answers (3)

entropo
entropo

Reputation: 2481

Perhaps you could take advantage of the git pre-commit hook? http://progit.org/book/ch7-3.html

Upvotes: 1

gunwin
gunwin

Reputation: 4832

create a ".gitconfig" file in your home directory (locally).

Containing the following:

[user]
    name = Your Name Comes Here
    email = [email protected]

Upvotes: 0

John Flatness
John Flatness

Reputation: 33749

If you write a simple script to prompt for the name and set it accordingly, you could then use that script in a pre-commit hook, and Git will call it for you just before making a commit.

Upvotes: 4

Related Questions