zoukankan      html  css  js  c++  java
  • git 初始化配置

    git 初始化配置

    git 配置文件作用优先级

    系统配置文件(—system) < 用户配置文件(—global) < 工作区配置文件(—local)

    git 初始配置

    1. 配置用户名和邮件

    git config --global user.name "zhangsan"

    git config --global user.mail zhangsna@tencent.com

    1. 配置文本编辑器

       git默认会调用vim作为默认文本编辑器,可以根据个人喜好设置相应的编辑器

    git config --global core.editor emacs

    3.支持utf-8编码

    git config --global core.quotepath false
    

    4.检查已经配置信息

    git config [--global/system] --list
    git config <key>  //获取某一项配置值,eg:  git config color.ui
    

        缺省模式会罗列所有config的配置值,其中可能存在重复,git会使用它找到的每一个变量的最后一个值
    5.获取帮助

    git help config
    

    6.缓存账号信息管理

    windows store
    git config --global credential.helper wincred 
    window unstore
    git config --global --unset credential.helper wincred
    linux/mac store
    git config --global credential.helper store
    linux/mac unstore
    git config --global credential.helper delete
    

    windows项目当更换系统账号密码后,若无法清理旧密码,可以采取如下命令清理git相关认证即可。

    rundll32.exe keymgr.dll,KRShowKeyMgr

    7.配置忽略文件

    cat .gitignore
    #忽略所有以.o.a 结尾的文件
    *.[oa] 
    #忽略所有以.~结尾的文件
    *~  
    xcuserdata/
    build/
    DerivedData/
    *.moved-aside
    *.class
    bin/
    *.dex
    .gradle/
    *.apk
    *.ap_

    8.别名设置

    git config --global alias.co checkout

    git config --global alias.ci commit

    git config --global alias.st status

    git config --global alias.unstage 'reset HEAD --' //git unstage fileA 等价于 git reset HEAD -- fileA

    git config --global alias.last 'log -1 HEAD' //git last 可以轻松看最后一次提交

    由于配置缺失,常见异常报错:

    1.解决本地语言不能展示中文问题:

    ----Warning: Your console font probably doesn't support Unicode. If you experience s trange characters in the output, consider switching to a TrueType font such as C onsolas!

    ———-windows 报错,git bash报 中文无法正常显示
    git config —global core.quotepath false
    2.and more ……

    ---来源于网络

  • 相关阅读:
    一文让你明白Redis持久化
    spring-data-redis 2.0 的使用
    中间自适应布局的5种解法
    php实现只需要一个QQ号就可以获得用户信息
    基于LINUX下的进程管理问题
    【初码干货】记一次分布式B站爬虫任务系统的完整设计和实施
    初码-爬虫系列-文章目录
    初码-阿里云系列-文章目录
    初码-Azure系列-存储队列的使用与一个Azure小工具(蓝天助手)
    初码-Azure系列-记一次MySQL数据库向Azure的迁移
  • 原文地址:https://www.cnblogs.com/w-j-q/p/14277520.html
Copyright © 2011-2022 走看看