/<Users>/.gitconfig file is used for all related information during commit.
This is how
.gitconfig file looks like:
[user] name = Crunchify email = email [at] crunchify.com [pull] rebase = false [commit] gpgSign = false [gui] pruneduringfetch = true [smartgit "submodule"] fetchalways = true update = true initializenew = true [push] recurseSubmodules = check
As you see above, there is tag called
[user] all git clients including smartGit picks up that
This is a big problem for your Work and Personal Github or Bitbucket account. You need to be very careful before committing to each repository.
By default hidden
.gitconfig file is use for both account and there is no way you could separate out different .gitconfig file for each account 🙁
If you have any of below questions then you are at right place:
- Setting your commit username and email address in Git
- Set GitHub email address on a per repository basis
- GIT – different config for different repository
- How can I change the author (name / email) of a commit?
- How to Change Author Name and Email of Commits on macOS?
- GitHub change email for repository
In this tutorial we will go over steps on how to use different setting for different repositories:
Clone your Work repository and Private repository to your laptop/desktop. Here is example I’ve shown total 5 Crunchify repositories.
We will use different username and email for each repository.
- Go to repository
- Click on hidden folder
[user] tag with username and email info. Here is a sample.
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true [remote "origin"] url = https://github.com/Crunchify/CrunchifyTutorials fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master [user] name = Crunchify, LLC email = email [at] crunchify.com
Using command line also you could to change the file.
- Open macOS Terminal.
- Change the current working directory to the local repository
- This is a repository where you want to configure the name that is associated with your Git commits.
- Execute command:
git config user.email "email [at] crunchify.com"
- Execute command:
git config user.name "Crunchify, LLC"
Now you could use different username/email for each separate github or bitbucket repository.