美文网首页
Git常用命令(一)

Git常用命令(一)

作者: 小田BSP | 来源:发表于2021-04-08 23:35 被阅读0次

    1、安装

    基于Ubuntu系统,git安装命令如下:

    ## 安装最小依赖性的主要组件
    apt-get install git
    或
    ## 安装包含所有sub-packages
    apt-get install git-all
    

    2、查看版本信息

    root@ubuntu:/home/run# git --version
    git version 2.17.1
    

    3、配置用户信息

    ## 配置用户名,例:run
    git config --global user.name run
    ## 配置邮箱,例:run@263.com
    git config --global user.email run@263.com
    ## 配置文本编辑器,例:vim
    git config --global core.editor vim
    ## 配置git着色
    git config --global color.ui auto
    
    ## 查看某个配置信息,例:user.email
    git config user.email
    ## 查看配置信息
    git config --list
    ## 查看配置信息及所在文件
    git config --list --show-origin
    

    例:

    ## 查看配置信息及所在文件
    root@ubuntu:/home/run/code/rockchip-bsp# git config --list --show-origin
    file:/root/.gitconfig   user.email=run@263.com
    file:/root/.gitconfig   user.name=run
    file:/root/.gitconfig   color.ui=auto
    file:/root/.gitconfig   core.editor=vim
    file:.git/config        core.repositoryformatversion=0
    file:.git/config        core.filemode=true
    file:.git/config        core.bare=false
    file:.git/config        core.logallrefupdates=true
    file:.git/config        submodule.active=.
    file:.git/config        remote.origin.url=https://github.com/radxa/rockchip-bsp.git
    file:.git/config        remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
    file:.git/config        branch.master.remote=origin
    file:.git/config        branch.master.merge=refs/heads/master
    file:.git/config        submodule.build.url=https://github.com/radxa/build.git
    file:.git/config        submodule.kernel.url=https://github.com/radxa/kernel.git
    file:.git/config        submodule.rkbin.url=https://github.com/radxa/rkbin.git
    file:.git/config        submodule.rootfs.url=https://github.com/radxa/rk-rootfs-build.git
    file:.git/config        submodule.u-boot.url=https://github.com/radxa/u-boot.git
    
    ## 查看配置文件
    root@ubuntu:/home/run/code/rockchip-bsp# cat ~/.gitconfig
    [user]
            email = run@263.com
            name = run
    [color]
            ui = auto
    [core]
            editor = vim
    

    注:

    1、git config -h查看其他参数。

    2、--global对应的配置文件:~/.gitconfig,只需要运行一次,针对当前用户。

    3、本地仓库的git配置文件:.git/config

    4、如果针对某个git仓库配置,可以省略--global或者替换为--local参数。

    5、每次git提交都会用到nameemail等信息。

    相关文章

      网友评论

          本文标题:Git常用命令(一)

          本文链接:https://www.haomeiwen.com/subject/cymbkltx.html