zoukankan      html  css  js  c++  java
  • Git学习笔记--配置(二)

    由之前文章,总结得出Git的特点:

    最优的存储能力;

    非凡性能;

    开源的;

    管理成本低;

    很容易做备份;

    支持离线操作;

    很容易定制工作流程;

    Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

    Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

    一、配置信息

    Git 自带一个 git config 的工具来帮助设置控制 Git 外观和行为的配置变量。 这些变量存储在三个不同的位置:

    1. /etc/gitconfig 文件: 包含系统上每一个用户及他们仓库的通用配置。 如果使用带有 --system 选项的 git config 时,它会从此文件读写配置变量。

    2. ~/.gitconfig~/.config/git/config 文件:只针对当前用户。 可以传递 --global 选项让 Git 读写此文件。

    3. 当前使用仓库的 Git 目录中的 config 文件(就是 .git/config):针对该仓库。

    1)配置user.name和user.email

    $ git config --global user.name 'your_name'
    $ git config --global user.email 'your_email@domian.com'

    ① config的三个作用域

    缺省等同于local

    $ git config --local         #local只对仓库有效
    $ git config --global        #global对登录用户所有仓库有效
    $ git config --system        #system对系统的所有用户有效

    显示config的配置。加--list

    $ git config --list --local       
    $ git config --list --global     
    $ git config --list --system 

    ② 设置与清除

    设置,缺省等同于local

    $ git config --local       
    $ git config --global    
    $ git config --system 

    清除,--unset

    $ git config --unset --local user.name       
    $ git config--unset --global user.name  
    $ git config --unset --system user.name

    ③ 优先级

    local > global >system

    每一个级别覆盖上一级别的配置,所以 .git/config 的配置变量会覆盖 /etc/gitconfig 中的配置变量。

    在 Windows 系统中,Git 会查找 $HOME 目录下(一般情况下是 C:Users$USER)的 .gitconfig 文件。 Git 同样也会寻找 /etc/gitconfig 文件,但只限于 MSys 的根目录下,即安装 Git 时所选的目标位置。

    二、文本编辑器

    既然用户信息已经设置完毕,你可以配置默认文本编辑器了,当 Git 需要你输入信息时会调用它。 如果未配置,Git 会使用操作系统默认的文本编辑器,通常是 Vim。 如果你想使用不同的文本编辑器,例如 Emacs,可以这样做:

    $ git config --global core.editor emacs

    Warning:

    Vim 和 Emacs 是像 Linux 与 Mac 等基于 Unix 的系统上开发者经常使用的流行的文本编辑器。 如果你对这些编辑器都不是很了解或者你使用的是 Windows 系统,那么可能需要搜索如何在 Git 中配置你最常用的编辑器。 如果你不设置编辑器并且不知道 Vim 或 Emacs 是什么,当它们运行起来后你可能会被弄糊涂、不知所措。

     三、获取帮助

    有三种方法可以找到 Git 命令的使用手册:

    $ git help <verb>
    $ git <verb> --help
    $ man git-<verb>

    例如,要想获得 config 命令的手册,执行

    $ git help config

    Git官网:

    https://git-scm.com/

    (文档:https://git-scm.com/book/zh/v2

    Github:

    https://github.com/

    GitLab:

    https://about.gitlab.com/

    SVN:

    https://subversion.apache.org/

  • 相关阅读:
    iOS应用崩溃日志分析
    使用Crashlytics来保存应用崩溃信息
    Mac和iOS开发资源汇总
    简单配置PonyDebugger
    程序员的工作不能用“生产效率”这个词来衡量
    使用Reveal 调试iOS应用程序
    MySQL 笔记
    flex弹性布局
    回调函数
    微信小程序开发
  • 原文地址:https://www.cnblogs.com/1693977889zz/p/10800667.html
Copyright © 2011-2022 走看看