relidon
relidon

Reputation: 2292

Is there a way to automatically change git username based on cloned repository url?

If I am cloning a repository from, say, bitbucket, I would like to use a different git username on my commits (git config user.name).

Is there a way to do this automatically. For example, if I run this in terminal

git clone [email protected]:...

Have it automatically set git config user.name to something I always want to use.

Upvotes: 0

Views: 201

Answers (1)

jthill
jthill

Reputation: 60295

Easy way is to make a "myclone" alias or however you want to do it, that adds the extra setup check. Most projects that need to deal with this have a .mailmap file (which Git supports natively) to set up alternate/superseded identity mappings to the project-specific preferred identity. With the mailmap if your project switches hosting you don't have to further customize and mistakes are trivial to deal with, it's just a question of what works best for you.

Upvotes: 1

Related Questions