Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting different config for different repositories [duplicate]

Tags:

git

github

People also ask

Can I have multiple git configs?

With conditional includes in Git 2.13, it is now possible to have multiple user/email coexist on one machine with little work. user. gitconfig has my personal name and email.

How do I mirror a git repository?

Navigate to the repository you just cloned. Pull in the repository's Git Large File Storage objects. Mirror-push to the new repository. Push the repository's Git Large File Storage objects to your mirror.


If you want to set up configurations that are specific for a particular repository, you have two options, to configure it from the command line, or edit the repo's config file in an editor.

Option 1: Configure via command line

Simply use the command line, cd into the root of your Git repo, and run git config, without the --system and the --global flags, which are for configuring your machine and user Git settings, respectively:

cd <your-repo>
git config <setting-name> <setting-value>
git config <setting-name>=<setting-value> # alternate syntax

Option 2: Edit config file directly

Your other option is to edit the repo config file directly. With a default Git clone, it's usually the .git/config file in your repo's root folder. Just open that file in an editor and starting adding your settings, or invoke an editor for it at the command line using git config --edit.

Resources

You can learn more about configuring Git at the official Linux Kernel Git documentation for git config. In particular, you may be interested in seeing an example Git config:

# Core variables
[core]
        ; Don't trust file modes
        filemode = false
# Our diff algorithm
[diff]
        external = /usr/local/bin/diff-wrapper
        renames = true
[branch "devel"]
        remote = origin
        merge = refs/heads/devel
# Proxy settings
[core]
        gitProxy="ssh" for "kernel.org"
        gitProxy=default-proxy ; for the rest
[include]
        path = /path/to/foo.inc ; include by absolute path
        path = foo ; expand "foo" relative to the current file
        path = ~/foo ; expand "foo" in your $HOME directory

Edit

Addressing the original poster's question about how to change user.name and user.email per repository, here is how to do it via the command line. Switch to each repository, and run the following:

git config user.name "<name>"
git config user.email "<email>"

Since you're not using the --system or the --global flags, the above commands will apply to whichever repo you have in your terminal working directory only.