使用Git命令心得总结---附上.gitconfig

标签: git命令总结git简写gitaliasgit心得
521人阅读 评论(0) 收藏 举报
分类:

前言

分享和汇总下工作中用GIT和小伙伴的一些命令及简写

.gitconfig


[user]
    email = crper@outlook.com
    name = LinQunHe
[status]
    relativePaths = true
    showUntrackedFiles = no
[alias]
    #亮瞎眼的日志输出
    ll = log --pretty=oneline --color --abbrev-commit
    lg = log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset %e'  --date=relative  --abbrev-commit
    last = log -1 --color  --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset %e'  --shortstat --abbrev-commit --stat
    rlg = log remotes/origin/master --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset %e'  --date=relative  --abbrev-commit

    #全局设置简写
    cg = config --global
    psuo =  push --set-upstream origin

    #全局设置输出
    cl = config --list

    #推送和拉取
    pso = push origin
    plo = pull origin

    #取消暂存
    unstage = reset HEAD

    #时光倒流
    rhlast = reset --hard HEAD^
    rh = reset --hard
    rhom = reset --hard origin/master
    unmerge = reset --hard ORIG_HEAD

    #状态提交
    adds = add *
    st = status
    sst = status -sb
    cm = commit -m
    rao = remote add origin

    #清除缓存,撤销commit信息
    rc = rm --cached
    cam = commit --amend

    #拉取合并分支
    f = fetch
    fo = fetch origin
    m = merge
    mo = merge origin

    #分支管理
    b = branch
    ba = branch -a
    br = branch -r
    brd = branch -d
    brdd = branch -D

    co = checkout
    cob = checkout -b
    podel = push origin --delete
    podelt = push origin --deleta tag
    pt = push --tags
    ft = fetch origin tag

    #暂存管理
    sth = stash
    lsth = stash list
    asth = stash apply
    dsth = stash drop

    #远程仓库管理
    r = remote
    rso  = remote show origin
    rseto = remte set-url origin


    #分支获取
    fm = fetch origin master
    mm = merge origin/master
[color]
    status = auto
    branch = auto
    interactive = auto
    diff = auto
    ui = 1
[color "branch"]
  current = yellow reverse
  local = yellow
  remote = green

[color "diff"]
  meta = yellow bold
  frag = magenta
  plain = white bold
  old = red bold
  new = green bold
  commit = yellow bold
  func = green dim
  #plain = white bold

[color "status"]
  added = yellow
  changed = green
  untracked = cyan

[push]
   default = tracking
[core]
    autocrlf = true
[grep]
    lineNumber = true

效果图

其他的没法演示,这里只能简单的演示下日志的输出

这里写图片描述


总结

有些小伙伴可能不习惯用使用命令行(命令行的快感倍儿爽),那么推荐使用SourceTree【可视化GIT管理】

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    博客专栏
    个人资料
    • 访问:671649次
    • 积分:7923
    • 等级:
    • 排名:第2603名
    • 原创:183篇
    • 转载:4篇
    • 译文:3篇
    • 评论:91条
    最新评论