Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is my git alias stored?

Tags:

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?

like image 506
idbrii Avatar asked Jul 31 '12 19:07

idbrii


People also ask

How do I edit a git alias?

Start a new branch. gitconfig file and add each alias under [alias], like so: Additionally, you can have repo-specific aliases. Just edit . git/config in the repo where you want to add the alias, and follow the same syntax.

What is git alias?

Git aliases are a powerful workflow tool that create shortcuts to frequently used Git commands. Using Git aliases will make you a faster and more efficient developer. Aliases can be used to wrap a sequence of Git commands into new faux Git command.


1 Answers

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 
like image 107
Matt Fenwick Avatar answered Oct 14 '22 23:10

Matt Fenwick