当前位置: 首页> 房产> 家装 > 站群cms系统_官网建设公司_关键词优化推广排名多少钱_上海疫情最新数据

站群cms系统_官网建设公司_关键词优化推广排名多少钱_上海疫情最新数据

时间:2025/7/13 12:53:28来源:https://blog.csdn.net/xiaohaha123258/article/details/147098409 浏览次数:0次
站群cms系统_官网建设公司_关键词优化推广排名多少钱_上海疫情最新数据

文章目录

  • 基本概述
  • 配置级别
  • 基本用法
    • 设置配置项
    • 查看配置项
    • 删除配置项
  • 常用配置项

基本概述

git config 的作用是:设置用户信息、编辑器、别名、仓库行为等。

配置级别

级别作用范围配置文件路径命令选项
仓库级别(Local)当前仓库.git/config无(默认选项)
全局级别(Global)当前用户
所有仓库
~/.gitconfig(Linux/macOS)
用户\xxx.gitconfig% (Windows)
- -global
系统级别(System)所有用户
所有仓库
/etc/gitconfig(Linux/macOS)
Git安装目录\etc\gitconfig(Windows)
- -system
  • 优先级从高到低为:系统 > 全局 > 仓库

基本用法

设置配置项

1.格式

git config [级别] [选项] <key> <value>

2.例子

# 设置用户名和邮箱(全局)
git config --global user.name "Your Name"
git config --global user.email "email@example.com"

查看配置项

1.查看所有配置项

# 查看所有配置项(含来源文件)
git config --list --show-origin

2.查看指定配置项

git config --get user.name

3.直接打开文件查看

$ cat .git/config
[core]repositoryformatversion = 0filemode = falsebare = falselogallrefupdates = truesymlinks = falseignorecase = trueeditor = code --wait
[gui]wmstate = normalgeometry = 1205x669+152+152 276 304
[remote "origin"]url = git@gitee.com:xxx1231/xxx.gitfetch = +refs/heads/*:refs/remotes/origin/*
[branch "local_branch"]remote = originmerge = refs/heads/local_branch
[init]defaultBranch = main

删除配置项

1.删除全局级别的配置

git config --global --unset user.email

2.删除所有级别的配置(慎用)

git config --unset-all user.name

常用配置项

1.用户信息

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
  • 必须配置名字和邮箱才能进行 commit 操作

2.默认文本编辑器

# 设置 VSCode 为默认编辑器
git config --global core.editor "code --wait"# 其他编辑器示例:
# Vim: git config --global core.editor "vim"
# Nano: git config --global core.editor "nano"

3.设置默认分支名称

git config --global init.defaultBranch main
  • 将默认分支从 “master” 改为 “main”

4. 凭证存储(避免重复输入密码)

# 使用缓存(默认15分钟)
git config --global credential.helper cache# 自定义缓存时间(例如1小时)
git config --global credential.helper "cache --timeout=3600"# 永久存储(慎用)
git config --global credential.helper store  # 明文保存到 ~/.git-credentials

5.配置别名(Alias)

# 简化常用命令
git config --global alias.st "status"
git config --global alias.br "branch"
git config --global alias.ci "commit"
git config --global alias.co "checkout"
  • 配置别名后,输入 git st ,就相当于输入了 git status
关键字:站群cms系统_官网建设公司_关键词优化推广排名多少钱_上海疫情最新数据

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: