• Git知识整理(持续更新)


    一、Git的安装及配置

    从官网下载直接安装即可。
    使用github或者gitee的时候,需要指定user.nameuser.email,而刚安装好的git是没有配置这两个内容的,不信的话,通过这个命令查看当前配置:

    git config --list
    
    • 1

    结果为:

    diff.astextplain.textconv=astextplain
    filter.lfs.clean=git-lfs clean -- %f
    filter.lfs.smudge=git-lfs smudge -- %f
    filter.lfs.process=git-lfs filter-process
    filter.lfs.required=true
    http.sslbackend=openssl
    http.sslcainfo=C:/Program Files/Git/mingw64/etc/ssl/certs/ca-bundle.crt
    core.autocrlf=true
    core.fscache=true
    core.symlinks=false
    pull.rebase=false
    credential.helper=manager
    credential.https://dev.azure.com.usehttppath=true
    init.defaultbranch=master
    core.repositoryformatversion=0
    core.filemode=false
    core.bare=false
    core.logallrefupdates=true
    core.symlinks=false
    core.ignorecase=true
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    很明显没有user.nameuser.email。配置也很简单,使用如下命令:

    git config --global user.name "your name"
    git config --global user.email "your email"
    
    • 1
    • 2

    此时再通过git config --list命令查看配置,就能看到已经配置好了:

    diff.astextplain.textconv=astextplain
    filter.lfs.clean=git-lfs clean -- %f
    filter.lfs.smudge=git-lfs smudge -- %f
    filter.lfs.process=git-lfs filter-process
    filter.lfs.required=true
    http.sslbackend=openssl
    http.sslcainfo=C:/Program Files/Git/mingw64/etc/ssl/certs/ca-bundle.crt
    core.autocrlf=true
    core.fscache=true
    core.symlinks=false
    pull.rebase=false
    credential.helper=manager
    credential.https://dev.azure.com.usehttppath=true
    init.defaultbranch=master
    
    // 多了这两个配置项
    user.name=xxx
    user.email=yyy
    
    core.repositoryformatversion=0
    core.filemode=false
    core.bare=false
    core.logallrefupdates=true
    core.symlinks=false
    core.ignorecase=true
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    二、跨系统配置之CSLF和LF

    Windows系统中,从第n行到第n+1行,用的是回车\r加换行\n,即Carriage ReturnLine Feed
    Mac和Linux系统中,从第n行到第n+1行,只用了换行\n,即Line Feed
    来自Mosh的课程
    git有CRLF机制,根据不同的操作系统,配置不同的策略。
    Windows系统,本地一直用CRLF,上传到Git仓库时用LF保存,下载到本地又转换为CRLF。
    Mac和Linux系统,本地用LF,上传到Git仓库时用LF保存,下载到本地依旧是LF。
    如果要手动配置的话,应该这样:
    Windows系统:

    git config --global core.autocrlf true
    
    • 1

    Mac和Linux系统:

    git config --global core.autocrlf input
    
    • 1
  • 相关阅读:
    MySQL 索引和事务
    leetcode刷题:二叉树23(二叉搜索树中的众数)
    网络通信:http协议
    美团面试——java开发岗
    【 java 常用类】你不知道的String
    (C++)何时使用引用、指针、按值传递作为参数的方法——(巧级好用的总结方法)
    Docker容器中的SSH免密登录
    python面试题之read、readline、readlines的区别
    第一次参加项目的经历(参加活动,获取高级背包)
    02. Springboot集成Flyway
  • 原文地址:https://blog.csdn.net/yuanchenglei/article/details/133717827