企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 配置文件的存储位置 1. `local`:本地文件存放在仓库中(`.git/config`),只针对当前仓库 2. `global`:全局文件存放为`~/.gitconfig`或`~/.config/git/config`,作用于当前用户的所有仓库 3. `system`:系统文件存放为`/etc/gitconfig`,作用于系统的每个用户 优先级 local > global > system ## 场景 ### 配置用户名和密码 ``` git config [--global ] user.name "idcpj" git config [--global] user.email "26008xx04@gmail.com" ``` ### 获取配置 ``` > git config --list core.autocrlf=true core.fscache=true core.symlinks=true pull.rebase=false user.email=2600xx04@qq.com ``` - 如果发现相同key的配置,因为git 从多个路径获取值 - 以最下面的值为准 ### 添加/删除配置项 格式 ``` git config [--local|--global|--system] <--add|--unset> section.key value ``` 实例 ``` // 添加 git config --global --add site.name yiibai // 删除 git config --local -–unset site.name ``` ### 编辑配置 ``` git config -e [--global] ``` ### 记住密码 方法一: ``` # Linux $ git config --global credential.helper store # MacOs $ git config --global credential.helper osxkeychain ``` 方法二[推荐]: `http://yourname:password@git.oschina.net/name/project.git `