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

相关推荐
weixin_433417672 小时前
TortoiseGit推送到远端,如何配置
windows·git
Hey_Coder19 小时前
【Git 常用命令速查表(按功能分类)】
git·git基础命令·git命令速查表·git 常用命令
colman wang21 小时前
Git指令(Mac)
git·macos
cyforkk1 天前
Git 合并分支提示 Already up to date 的真实原因
git
●VON1 天前
HarmonyKit | 移动端开发者工具类应用的现状与趋势
git·华为·性能优化·harmonyos·鸿蒙
●VON1 天前
HarmonyKit | 鸿蒙开发协作:如何为 HarmonyKit 贡献一个新的工具
git·华为·harmonyos·鸿蒙
枕星而眠1 天前
Git仓库基础用法
大数据·git·后端·elasticsearch·全文检索
酷虎软件1 天前
分享链接+视频音频文案提取 API 接口文档
ide·macos·xcode
梦想三三2 天前
Git与GitHub基础入门:从零开始掌握版本控制与代码托管(完整图文教程)
人工智能·git·elasticsearch·github
Hyyy2 天前
为什么 macOS 应用一换 Bundle ID,之前授予的权限就全失效了?
macos·electron