安装Homebrew安装Git(Mac)

使用Homebrew安装Git(Mac)

1 安装Xcode

安装Homebrew之前,需要安装Xcode Comand Line Tools:

xcode-select --install

2 安装Homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装完成后,Homebrew的主程序安装在/usr/local/bin/brew,在目录/usr/local/Library/Formula/下保存了所有Homebrew支持的软件的安装指引文件。

3 使用Homebrew安装Git

brew install git

使用Homebrew方式安装,Git被安装在/usr/local/Cellar/git/2.21.0路径下。

安装完成后,使用如下命令查看Git版本:

git --version

4 配置GitHub中的SSH key值

4.1 输入如下命令产生新的key

ssh-keygen -t rsa -C "your_email@example.com"

4.2 将SSH key添加到Github

登录到Github页面 -> 右上角Setttings -> SSH keys ->Add key

查看生成的key内容:

cat ~/.ssh/id_rsa.pub

将以上内容复制到Key所对应的输入框中并保存。

详见:Github的搭建和配置github中的SSH key值

5 配置Git用户信息

git config --global user.name "你的名字或昵称"

git config --global user.email "你的邮箱"

6 提交第一行代码

git clone https://gitlab.testgu.com/ycyzharry/HelloGit.git #将远程仓库克隆到本地

git add . #将当前目录所有文件添加到git暂存区

git commit -m "my first commit" #提交并备注提交信息

git push origin master #将本地提交推送到远程仓库

相关推荐
2501_91590906几秒前
MachObfuscator全面解析:Apple平台Mach-O应用程序混淆技术指南
macos·ios·小程序·uni-app·objective-c·cocoa·iphone
vistaup12 小时前
windows git 更新当前目录下所有的文件(非递归)
windows·git
王码码203512 小时前
Flutter for OpenHarmony:Flutter 三方库 algoliasearch 毫秒级云端搜索体验(云原生搜索引擎)
android·前端·git·flutter·搜索引擎·云原生·harmonyos
待续30114 小时前
OpenClaw 安装及使用教程(Windows / macOS / Linux)
linux·windows·macos
Irene199116 小时前
Git 命令汇总表(基于一次完整的 Git 实战经验整理,涵盖从安装配置到日常开发、问题排查的所有常用命令)
git·常用命令
q54314708717 小时前
Redis Desktop Manager(Redis可视化工具)安装及使用详细教程
redis·git·bootstrap
阿正的梦工坊18 小时前
在Mac电脑上如何显示点(.)开头的隐藏文件
macos
素雨迁喜18 小时前
Linux平台下git工具的使用
linux·运维·git
AI-小柒18 小时前
DataEyes 聚合平台 + Claude Code Max 编程实战
android·开发语言·人工智能·windows·python·macos·adb
Irene199120 小时前
Windows环境,VS Code 中 Git 配置指南
git·基础配置