Git 配置指南 💻
Git 是现代开发中不可或缺的版本控制工具,以下是常见配置项说明:
1. 全局配置 📝
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
为避免重复设置,建议通过
git config --list
查看当前配置
点击了解配置文件详解
2. 常用别名设置 🔄
git config alias.co checkout
git config alias.br branch
git config alias.st status
可自定义命令缩短操作长度
查看别名实战案例
3. 默认分支设置 🌐
git config init.defaultBranch main
注意:部分旧版本需使用
master
作为默认分支名称
Git_Logo
图片关键词:Git_Logo
4. 远程仓库管理 ⚙️
git remote add origin https://github.com/yourname/repo.git
git remote set-url origin https://new-url.com
通过
git remote -v
可查看远程仓库信息
深入学习远程操作
5. 高级配置建议 📚
core.editor
:设置默认文本编辑器push.default
:配置推送行为(推荐设置为simple
)merge.tool
:指定合并工具(如meld
或vscode
)
配置修改后建议运行
git config --list
验证效果
查看完整配置文档