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

相关推荐
朋友圈自动点赞工具5 小时前
Gmail 委托邮箱在手机上关不掉
macos·智能手机·cocoa·硬件评测
小黄人软件6 小时前
AndroidStudio老项目 macOS运行BlueTooth蓝牙串口助手(Android+Studio源码).rar
android·macos
她说..8 小时前
IntelliJ IDEA 快捷键速查表(Mac 版)
java·macos·intellij-idea
louisgeek12 小时前
Git submodule 子模块
git
for_ever_love__12 小时前
iOS: CABasicAnimation动画
macos·ios·cocoa
imDwAaY12 小时前
6篇文章讲清楚Git:Git 实用技巧:暂存现场、挑选提交与定位 Bug (5/6)
git·后端
imDwAaY13 小时前
6篇文章讲清楚Git:Git 团队开发实践:从 Pull Request 到版本发布 (6/6)
git·后端
ITKEY_13 小时前
Mac mini彻底禁止自动睡眠
macos
誰能久伴不乏1 天前
看懂 Git 团队协作全流程:分支、提交、PR、rebase 到底在干嘛
git
sunshine22 girl1 天前
git tag-项目流程
git