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

相关推荐
码厂一粒沙4 小时前
【代码管理】git使用指南(新手向)
git
2501_9151063210 小时前
iOS 26 能耗监测全景,Adaptive Power、新电池视图
android·macos·ios·小程序·uni-app·cocoa·iphone
李贺梖梖13 小时前
Git初识
git
~央千澈~13 小时前
git大文件储存机制是什么-为什么有大文件会出错并且处理大文件非常麻烦-优雅草卓伊凡
git
Python私教13 小时前
5分钟上手 MongoDB:从零安装到第一条数据插入(Windows / macOS / Linux 全平台图解)
windows·mongodb·macos
Komorebi_999914 小时前
Git 常用命令完整指南
大数据·git·elasticsearch
stark张宇16 小时前
Git 与 GitHub 协同工作流:从0到1搭建版本控制体系
git·gitlab·github
爱吃生蚝的于勒16 小时前
【Linux】零基础学会Linux之权限
linux·运维·服务器·数据结构·git·算法·github
minji...17 小时前
Linux相关工具vim/gcc/g++/gdb/cgdb的使用详解
linux·运维·服务器·c++·git·自动化·vim
Arva .1 天前
开发准备之日志 git
spring boot·git·后端