安装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 #将本地提交推送到远程仓库

相关推荐
小天源34 分钟前
智叟云集系统:便携部署、MAC 授权与交付排障
macos
Joy T6 小时前
voice-dump-to-todo:把混乱的语音整理成可执行待办,一个实用的 Agent Skill
ide·macos·语音识别·xcode·任务管理·自研skill
LannyChung10 小时前
PowerShell 下 git log 中文乱码的完整排查与解决
windows·git
import_random11 小时前
[git]本地main,origin/main,远程main(关系2)
git
golang学习记11 小时前
Zed Git重大更新:目录级对比支持分栏Diff
git·vscode·zed
JPower_mr.g13 小时前
SmartCall v1.0.9 发布:智能体知识库上线,让 AI 客服先查资料再回答
java·ide·人工智能·macos·架构·开源·xcode
轻口味15 小时前
启元无真机二开实战:先在Mac上养一台Q1——官方URDF到MuJoCo数字孪生的完整链
macos·具身智能·mujoco·启元机器人
阿俊-全栈开发16 小时前
LikeShop 单商户高级版二开项目的 Git 分支管理与版本发布规范
git·likeshop·likeshop开源商城·likeshop多商户
努力弹琴的大风天16 小时前
TortoiseGit 仓库不显示绿色对号解决方案
git·tortoisegit·图标显示
我不会插花弄玉19 小时前
GitHub实操【由浅入深-Git】
git·github