git选项列表:git config --help
git的配置列表:git config --list
git remote add 和git config设置的参数是加上都是配置在git的配置文件中的。其中git remote添加的仓库Url链接信息是保存在项目目录.git/config文件中,这是项目级的配置文件。而git config设置的global信息保存在用户级的配置文件中,该文件的位置为用户目录~/.gitconfig。实际上git还有一个系统级的配置文件,该文件位于/etc/gitconfig。配置文件生效生效优先级是先项目(.git/config),后用户(~/.gitconfig),最后系统(/etc/gitconfig)。由于git的使用都是以用户级的,所以我们日常用的最多都是通过用户级别的配置
从system-》global-》local 底层配置会覆盖顶层配置 分别使用--system/global/local 可以定位到配置文件
查看系统config: git config --system --list
查看当前用户(global)配置:git config --global --list
查看当前仓库配置信息:git config --local --list
命令行配置: git config --global user.name "username" git config --global user.email "email"
--global 表示全局的,即当前用户都有效,该配置会出现在 ~/.gitconfig/C:\Users\username\.gitconfig 文件中
局部配置:git config user.name "username" git config user.email "email"
局部变量覆盖全局变量!!!局部是只对当前仓库起效的,它的配置信息会在当前仓库根目录/.git/config
修改本地仓库的用户名和邮箱:git config --replace-all user.name "name" git config --replace-all user.email "123@qq.com"
查看配置:git config user.name git config user.email
删除配置: git config --unset --global user.name
git 配置密钥 cd ~/.ssh 首次创建是没有.ssh文件
ssh-keygen -t rsa -C xxxxx@gmail.com
把公钥id_rsa.pub 的内容放在git仓库中
测试是否成功 仅限git bash 终端不可用
ssh -T git@github.com
结果
Hi coiggahou! You've successfully authenticated, but GiHub does not provide shell access.
命令骚操作
git config --global alias.快捷名 命令名
删除 git config --global --unset alias.别名名
文件中配置
可以配置一些命令行的别名,颜色等等
[alias]
br = branch
ct = commit
[color]
ui = auto
[color "branch"]
current = yellow reverse
引用
https://baijiahao.baidu.com/s?id=1623254575291831567&wfr=spider&for=pc