zoukankan      html  css  js  c++  java
  • Git一些其它的功能

    Git 开始之前我们配置过user.name和user.email.其实还有很多其他的配置项

    例如:让Git显示颜色,会让命令输出来更醒目:

    $ git config --global color.ui true  

    配置别名 

    有没有经常敲错命令的?比如git status?

    我们可以给命令起个别名

    LV@LV-PC MINGW32 ~
    $ git config --global alias.st status

    LV@LV-PC MINGW32 /c/gitskill (master)
    $ git st
    On branch master
    Your branch is up-to-date with 'origin/master'.
    nothing to commit, working directory clean

    LV@LV-PC MINGW32 /c/gitskill (master)
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    nothing to commit, working directory clean

    是不是git st 和git status的执行结果一样呢?

    当然还可以简写很多命令,很多人都用co表示checkout,ci表示commit,br表示branch

    LV@LV-PC MINGW32 /c/gitskill (master)
    $ git config --global alias.ci commit

    LV@LV-PC MINGW32 /c/gitskill (master)
    $ git config --global alias.co checkout

    LV@LV-PC MINGW32 /c/gitskill (master)
    $ git config --global alias.br branch

    --global参数是全局参数,也就是这些命令在这台电脑上的所有Git仓库都有用

    $ git config --global --list
    user.email=lvloveyuforever@gmail.com
    user.name=mars
    alias.st=status
    alias.co=checkout
    alias.ci=commit
    alias.br=branch

    在撤销修改一节中,命令git reset HEAD file可以把暂存区的修改撤销掉(unstage),重新放回工作区,既然是一个unstage操作,

    就可以配置一个unstage别名:

    $ git config --global alias.unstage 'reset HEAD'

    当你敲入命令:

    $ git unstage test.txt

    相当于执行了:

    $ git reset HEAD test.txt

    配置一个git last 让其显示最后一次信息

    $ git config --global alias.last 'log -1'

    简化命令,自己看着怎么好记,就怎么玩

    像把git config --global alias.lg "log --graph --pretty=oneline --abbrev-commit"

  • 相关阅读:
    【线型DP】【LCS】洛谷P4303 [AHOI2006]基因匹配
    【状压DP】SCOI2005-洛谷P1896-互不侵犯 (状压例题)
    【01背包】百度之星--度度熊剪纸条
    【线型DP】CF1012C Hills 小山坡
    【经典DP】洛谷P2285 [HZOI]2004 打鼹鼠
    【盗版动归】Codeforces998C——Convert to Ones 归一操作
    MySQL使用笔记(1)
    大学物理——光的干涉和衍射(2)
    大学物理——光的干涉和衍射(1)
    hdu5747 Aaronson 贪心
  • 原文地址:https://www.cnblogs.com/LvLoveYuForever/p/5527275.html
Copyright © 2011-2022 走看看