zoukankan      html  css  js  c++  java
  • git config配置快捷命令

    二、基本面

    git的alias是通过配置文件进行定制的,这个配置文件能做的事情还有很多,远远超过这篇文档的主题。

    git的全局配置文件一般叫做.gitconfig,当前仓库的配置文件是.git目录下的config文件。很明显,这俩配置文件的作用范围是不同的。

    三、使用git alias

    首先要修改配置文件

    3.1 linux

    我用的是ubuntu 12.04 LTS版本,其它的发行版可能会略有区别.

    第一步 用你最喜欢的编辑器打开 ~/.gitconfig

    第二步 再配置文件中加入alias块,内容如下,根据你的偏好进行修改

    配置

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    [alias]

        co = checkout

        ss = status

        cm = commit -m

        br = branch

        bm = branch -m

        bd = branch -D

        cb = checkout -b

        df = diff

        ls = log --stat

        lp = log -p

        plo = pull origin

        plode = pull origin develop

        pho = push origin

    第三步 试试管用吗

    3.2 windows

    windows系统的配置文件一般是位于git安装目录下的etcgitconfig文件。

    备注

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    co = checkout // 切换分支,或去到特定的commit

    ss = status

    cm = commit -m

    br = branch

    bm = branch -m  // 修改当前分支的名称

    bd = branch -D  // 删除某个分支

    cb = checkout -b    // 新建一个和当前分支一样的分支,并切换过去

    df = diff

    ls = log --stat // 查看每次提交修改了哪些文件, git ls -n, 只看最近的n次提交

    lp = log -p // 查看每次提交修改了那些行,git lp -n, 只看最近n次提交

    plo = pull origin

    pho = push origin

    2.配置用户名和邮箱

    全局

    $ git config --global user.name  ygtzz
    $ git config --global user.email ygtzz@126.com

    局部(当前项目)

    $ git config user.name  ygtzz
    $ git config user.email ygtzz@126.com

    3.快速打开gitconfig

    git config [--global] --edit

    4.修改编辑器

    $ git config --global core.editor emacs

    5.查看gitconfig内容

    $ git config --list

    git alias配置

    [alias]
    st = status -sb
    co = checkout
    br = branch
    mg = merge
    ci = commit
    ds = diff --staged
    dt = difftool
    mt = mergetool
    last = log -1 HEAD
    latest = for-each-ref --sort=-committerdate --format="%(committername)@%(refname:short) [%(committerdate:short)] %(contents)"
    ls = log --pretty=format:"%C(yellow)%h %C(blue)%ad %C(red)%d %C(reset)%s %C(green)[%cn]" --decorate --date=short
    hist = log --pretty=format:"%C(yellow)%h %C(red)%d %C(reset)%s %C(green)[%an] %C(blue)%ad" --topo-order --graph --date=short
    type = cat-file -t
    dump = cat-file -p
    lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
    [core]
    autocrlf = true
    [push]
    default = simple
    git config --list  
    
    core.symlinks=false
    core.autocrlf=true
    core.fscache=true
    color.diff=auto
    color.status=auto
    color.branch=auto
    color.interactive=true
    help.format=html
    http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
    diff.astextplain.textconv=astextplain
    rebase.autosquash=true
    credential.helper=manager
    user.name=zyc
    user.email=zyc@163.com
    alias.co=checkout
    alias.st=status
    alias.df=diff
    alias.ss=status -s
    alias.cm=commit -m
    alias.br=branch
    alias.bm=branch -m
    alias.bd=branch -D
    alias.cb=checkout -b
    alias.ll=log --graph --pretty=format:'%Cred%h%Creset %C(bold blue)%s%Creset %Cgreen(%cr) <%an>%Creset' --abbrev-commit --date=relative
    alias.lg=log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %C(bold blue)%s%Creset %Cgreen(%cr) <%an>%Creset' --abbrev-commit --date=relative
    alias.alg=log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %C(bold blue)%s%Creset %Cgreen(%cr) <%an>%Creset' --abbrev-commit --date=relative --all
    alias.ls=log --stat
    alias.plo=pull origin
    alias.pho=push origin
    正因为当初对未来做了太多的憧憬,所以对现在的自己尤其失望。生命中曾经有过的所有灿烂,终究都需要用寂寞来偿还。
  • 相关阅读:
    seata原理
    activemq 启动时出现错误 Address already in use: JVM_Bind
    高并发第五弹:安全发布对象及单例模式
    高并发第三弹:线程安全原子性
    高并发第一弹:准备阶段 了解高并发
    CentOS7安装PostgreSQL9.4
    高并发第二弹:并发概念及内存模型(JMM)
    高并发第四弹:线程安全性可见性有序性
    设计模式模板方法模式
    设计模式建造者模式(图解,使用场景)
  • 原文地址:https://www.cnblogs.com/candlia/p/11920092.html
Copyright © 2011-2022 走看看