Git配置信息相关命令

查看git所有配置项

$ git config -l
or
$ git config --list

全局配置用户名邮箱

$ git config --global user.name "young"
$ git config --global user.email "[email protected]"

根据项目配置:

  • 切换到项目目录下,配置用户名和密码:
$ git config user.name "young"
$ git config user.email "[email protected]"
  • 配置信息的存储位置
对应的本地仓库的.git文件中的config文件
在当前项目目录下使用 cat .git/config,就可以看到配置文件内容
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url = https://github.com/***/***.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

git config解析

[email protected]
user.name=leo
core.ignorecase=false            # 不许忽略文件名大小写
core.autocrlf=input              # 换行模式为 input,即提交时转换为LF,检出时不转换
core.filemode=false              # 不检查文件权限
core.safecrlf=true               # 拒绝提交包含混合换行符的文件
core.editor=vim
core.repositoryformatversion=0   # Internal variable identifying the repository format and layout version
core.bare=false                  # 默认不创建裸仓库
core.logallrefupdates=true       # log 所有 ref 的更新
core.precomposeunicode=true      # Mac专用选项,开启以便文件名兼容其他系统
push.default=simple                    # 只推送本地当前分支,且与上游分支名字一致
alias.lg=log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
pull.rebase=true                 # 强制开启 rebase 模式
credential.helper store // 记住密码

// 推荐配置
git config --global user.email “[email protected]"
git config --global user.name=mtide
sudo git config --system core.ignorecase false
sudo git config --system core.autocrlf input
sudo git config --system core.filemode false
sudo git config --system core.safecrlf true
sudo git config --system core.editor vim
sudo git config --system core.repositoryformatversion 0
sudo git config --system core.bare false
sudo git config --system core.logallrefupdates true
sudo git config --system core.precomposeunicode true
sudo git config --system push.default simple
sudo git config --system alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
sudo git config --system pull.rebase true
sudo git config credential.helper store // 记住密码

配置记住密码

[core]
        autocrlf = true
        excludesfile = C:\\Users\\lixinglong\\Documents\\gitignore_global.txt
[user]
        name = leo
        email = leo@***.cn
[credential]
    helper = store // 这样配置就会记住密码了

git全局配置修改

$ git config -e --global

进入全局配置文件,击字母i,进入编辑状态,修改里面的内容。

连接远程仓库相关命令

// 查看git远程库信息
$ git remote -v

// 查看remote地址,远程分支,还有本地分支与之相对应关系等一系列信息
$ git remote show origin

参考文章:https://blog.csdn.net/weixin_33768153/article/details/81026687

猜你喜欢

转载自www.cnblogs.com/russellyoung/p/Git-pei-zhi-xin-xi-xiang-guan-ming-ling.html
今日推荐