Where is my git alias stored?

11,527

Solution 1

There is no difference between using the undocumented (or is it obsolete) --local flag and no flag. Git never looks for a gitconfig in your repository root ($repo_path/.gitconfig). Repo-local config changes are in .git/config.

git help config explains the valid options:

--global For writing options: write to global ~/.gitconfig file rather than the repository .git/config.

   For reading options: read only from global ~/.gitconfig rather than from
   all available files.

--system For writing options: write to system-wide $(prefix)/etc/gitconfig rather than the repository .git/config.

   For reading options: read only from system-wide $(prefix)/etc/gitconfig
   rather than from all available files.

(Using git version 1.7.9)

You could try searching with this (from your repo root and assuming git is installed in /bin):

grep subaddvim .git/config ~/.gitconfig /etc/gitconfig

Solution 2

Scott Chacon's excellent book "Pro Git" covers where things are stored, and what options to pass to git config to read/write to that location:

Git comes with a tool called git config that lets you get and set configuration variables that control all aspects of how Git looks and operates. These variables can be stored in three different places:

  • /etc/gitconfig file: Contains values for every user on the system and all their repositories. If you pass the option --system to git config, it reads and writes from this file specifically.

  • ~/.gitconfig file: Specific to your user. You can make Git read and write to this file specifically by passing the --global option.

  • config file in the git directory (that is, .git/config) of whatever repository you’re currently using: Specific to that single repository. Each level overrides values in the previous level, so values in .git/config trump those in /etc/gitconfig.

You can have git tell you what's defined where using the --list option:

# shows all settings
git config --list

# shows system settings
git config --list --system

# shows user settings
git config --list --global

# shows project settings
git config --list --local
Share:
11,527

Related videos on Youtube

idbrii
Author by

idbrii

(my about me is no longer blank)

Updated on June 25, 2022

Comments

  • idbrii
    idbrii almost 2 years

    I have an alias that I cannot find. Typing git help subaddvim gives me:

    `git subaddvim' is aliased to `log HEAD'
    

    I think I defined it like this:

    git config --local alias.subaddvim 'log HEAD'
    

    I looked in $repo_path/.gitconfig, ~/.gitconfig, /etc/gitconfig, but none of them have a subaddvim entry.

    Where else can I look?

  • Hareen Laks
    Hareen Laks over 5 years
    I opened the .gitconfig file in installed folder. But I couldn't see any alias which I already have. Simply, I cannot found the text file where the alias have written.
  • idbrii
    idbrii over 5 years
    @HareenLaks Did you try the grep command at the end of the answer? Replace subaddvim with the alias you're looking for.