Convert Git Config (.gitconfig) to JSON
Convert Git configuration files (.gitconfig, .git/config) to JSON format. Covers user, core, alias, and other standard Git config sections.
Common Files
Detailed Explanation
Git Config to JSON
Git's configuration files (~/.gitconfig, .git/config, /etc/gitconfig) use INI format with sections and subsections. They control Git's behavior for user identity, aliases, merge strategies, diff tools, and more.
Example .gitconfig
[user]
name = Jane Developer
email = jane@example.com
signingkey = ABC123DEF456
[core]
editor = code --wait
autocrlf = input
pager = delta
excludesfile = ~/.gitignore_global
[alias]
co = checkout
br = branch
ci = commit
st = status
lg = log --oneline --graph --decorate --all
unstage = reset HEAD --
[pull]
rebase = true
[push]
default = current
autoSetupRemote = true
[merge]
conflictstyle = diff3
tool = vscode
[diff]
colorMoved = default
algorithm = histogram
Generated JSON
{
"user": {
"name": "Jane Developer",
"email": "jane@example.com",
"signingkey": "ABC123DEF456"
},
"core": {
"editor": "code --wait",
"autocrlf": "input",
"pager": "delta",
"excludesfile": "~/.gitignore_global"
},
"alias": {
"co": "checkout",
"br": "branch",
"ci": "commit",
"st": "status",
"lg": "log --oneline --graph --decorate --all",
"unstage": "reset HEAD --"
},
"pull": {
"rebase": true
},
"push": {
"default": "current",
"autoSetupRemote": true
},
"merge": {
"conflictstyle": "diff3",
"tool": "vscode"
},
"diff": {
"colorMoved": "default",
"algorithm": "histogram"
}
}
Git-Specific Considerations
- Boolean values: Git uses
true/falsewhich map directly to JSON booleans - Alias values: Git aliases are command strings that may contain flags and pipes, preserved as strings
- Subsections: Git supports
[section "subsection"]syntax (e.g.,[remote "origin"]). The quoted subsection name is included in the section key - Multi-valued keys: Some Git config keys accept multiple values; use "As array" mode to capture them all
- Path expansion: Values like
~/.gitignore_globalremain as literal strings — tilde expansion happens at Git runtime
Use Case
Creating a team Git configuration template system that stores standardized .gitconfig settings as JSON, allows team leads to customize settings through a configuration portal, and generates individual .gitconfig files for team members.