Git git config 配置使用

配置指令

git 的配置指令是 git config。用于配置git的用户,邮箱, 域名等信息。

配置级别

config 配置有3个层级, 优先级依次为:local>global>system。优先读取local,其次是global,最后是system。

  • system(系统级别)
  • golbal(用户级别)
  • local(仓库级别)
如何查看配置
  1. 查看系统config

    git config --system --list 
    
  2. 查看当前用户配置

    git confg --global --list
    
  3. 查看当前仓库的配置信息

    git config --local --list
    
如何配置
git config --global user.name "test"
git config --global user.email "test@163.com"
git config 常用配置
[user]
        name = test
        email = test@163.com
[credential]
        helper = cache --timeout=8640000
[push]
        default = simple
[color]
        ui = true
        status = auto
        branch = auto
[alias]
        st = status -s
        br = branch
			  df = diff
        ci = commit
        co = checkout
        lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
[filter "lfs"]
        required = true
        clean = git-lfs clean -- %f
        smudge = git-lfs smudge -- %f
        process = git-lfs filter-process
[difftool "sourcetree"]
        cmd = opendiff \"$LOCAL\" \"$REMOTE\"
        path = 
[mergetool "sourcetree"]
        cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
        trustExitCode = true
[core]
        excludesfile = /Users/rain/.gitignore_global
[commit]
        template = /Users/rain/.stCommitMsg
找不到.gitconfig文件具体位置时的解决方法

在终端输入命令进入 vim编辑模式

git config --global --edit

使用强制保存命令 :wq! 即可解决权限不够的问题

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值