git config配置快捷命令

摘要:
git的全局配置文件通常称为。gitconfig。当前仓库的配置文件是中的配置文件。git目录。显然,两个配置文件的范围不同。

二、基本面

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

免责声明:文章转载自《git config配置快捷命令》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇linux下ssh的几种验证方式NFS(网络文件系统)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

vue中使用Ueditor编辑器

一、 下载包: 从Ueditor的官网下载1.4.3.3jsp版本的Ueditor编辑器,官网地址为:       http://ueditor.baidu.com/website/ 下载解压后会得到如果下文件目录: 将上述Ueditor文件夹拷贝到vue项目的static文件夹中,此文件夹为项目的静态服务文件夹; 二、 修改配置 在ueditor.c...

[转]lamp的phpadmin安装

 1. 下载phpMyAdmin-3.3.7(在https://www.phpmyadmin.net/downloads/  中找到自己要下载的版本)       wget http://sourceforge.net/projects/phpmyadmin/files%2FphpMyAdmin%2F3.3.7%2FphpMyAdmin-3.3.7-all...

IntelliJ IDEA 更新

  一. 下载最新版本的idea          1. 官网下载,官网地址:http://www.jetbrains.com/idea/download/#section=windows          2. 百度网盘直接下载:https://pan.baidu.com/s/1qmNhRI7lSo9G-QEMDPQZfg , 密码:1jxd   二....

npm下载包时代理配置

主要有两种方式,1通过命令行临时配置,2通过配置文件进行永久配置。 1、命令行: npm install --proxy http://localhost:1080 如果有账号密码等验证的,需要在后面的url地址上加上。 2、通过config进行配置文件的写入,实现全局: 普通: npm config set proxy http://server:por...

npm配置文件

npm获取配置的方式,优先级由高到底。 命令行参数。 以设置代理为例:--proxy http://server:port即将proxy的值设为http://server:port。 环境变量。 以npm_config_为前缀的环境变量将会被认为是npm的配置属性。以设置proxy为例可以加入这样的环境变量npm_config_proxy=http://s...

Visual Studio 14 初试,vNext

 下了几天的VS 2014 .终于安装上了,花了好几天时间,  VS 2014  下载地址, http://www.visualstudio.com/en-us/downloads/visual-studio-14-ctp-vs http://download.microsoft.com/download/A/E/A/AEA8A39F-E281-448E-...