大家好,欢迎来到IT知识分享网。
文章目录
1.Mac Git 安装
Mac一般自带Git工具,也就是说已经安装好了 ,如果没有安装,可以去官网下载安装,或者直接使用 homebrew 指令下载(前提已经安装了 homebrew )
#命令 brew install git
官网提供的方式: https://git-scm.com/download/mac
2. 开发者工具
过程中遇到下面异常时
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
这个错误提示表明系统中的开发者工具路径存在问题,可能是缺少或无效的 CommandLineTools。
安装 CommandLineTools
#命令 xcode-select --install
安装完成,错误解决
3. git 账户配置
账户设置
#命令 :这里是全局账户设置,所有的仓库都是同一个账户 git config --global user.name "your_name" git config --global user.email "" #若每个仓库一种账户名,就不是这种配方方法。需要单独配置
生成秘钥
#命令 ssh-keygen -t rsa -C ""
密钥生成成功后,一般会在本地的/Users/用户名/.ssh目录下会生成id_rsa、id_rsa.pub两个文件
id_rsa文件:私钥,保存于本地;
id_rsa.pub文件:公钥,需要把里面内容配置到远端仓库(全部复制过去)。
git 或者 gitee 仓库添加公钥
查看全局账户命令
#查看是否全局配置过Git用户名和邮箱 git config --global user.name git config --global user.email #全局配置Git用户名和邮箱 git config --global user.name "xxx" git config --global user.email "" #删除全局配置的Git用户名和邮箱 git config --global --unset user.name git config --global --unset user.email
多账户设置
在 Mac 上配置 Git 多账户(比如 GitHub 和 Gitee)的步骤如下:
ssh-keygen -t rsa -C ""
这里的 应该替换为你在 GitHub 和 Gitee 上注册的邮箱。
- 添加 SSH 密钥到 SSH 代理
运行以下命令,将 SSH 密钥添加到 SSH 代理中:
ssh-add ~/.ssh/id_rsa_gitlab ssh-add ~/.ssh/id_rsa_gitee
这里的 id_rsa_gitlab和 id_rsa_gitee 应该替换为你生成的 SSH 密钥的文件名。
config文件
MAC系统如果升级到13.0之后,可能会拉取失败,可以尝试在.ssh/目录的 config文件(没有可以新建) 进行如下配置
# Gitee Host gitee.com HostName gitee.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa
测试连接
注意:生成的公钥,需要把里面内容配置到远端仓库(全部复制过去),否则会 permission denied。
我绑定的是gitee
#测试 ssh -T
会生成一个 新的文件 know_hosts
ssh -T
最终的 config 文件
clone到本地
成功配置后,就能用git 各种命令去操作 仓库文件了。
成功下载文件到本地。
当 git 配置成功后,也可以用 GUI 工具去管理仓库文件,比如 snailSVN, Smartgit, Github Desktop。这些工具都是支持MAC的。
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/119554.html
![[git] MacBook 安装git插图1 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/ea37e03f431047cf9e3f4c58e59e9360.png)
![[git] MacBook 安装git插图3 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/a3606d83c2344252a7d49dffebd4ea4d.png)
![[git] MacBook 安装git插图5 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/0a7de77da0e141659eab1189ffa033dd.png)
![[git] MacBook 安装git插图7 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/37bc6a24cf584764a96aee233ff749f4.png)
![[git] MacBook 安装git插图9 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/f19994a976014e288dbffa7ed46928ff.png)
![[git] MacBook 安装git插图11 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/2355e1477cbd4f90b7bdf5eaa9fcbccf.png)
![[git] MacBook 安装git插图13 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/fe7f6fdc28cf4056b19443b530539b63.png)
![[git] MacBook 安装git插图15 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/a9a44ac8aa6042c3aa4859f112452493.png)
![[git] MacBook 安装git插图17 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/9401b4741ebd45a799a0812c324b59af.png)
![[git] MacBook 安装git插图19 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/53bd4f4ccc1e4bb091c76398747d2179.png)
![[git] MacBook 安装git插图21 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/aebefc57ac2b4737bb7ca2003d9f805e.png)
![[git] MacBook 安装git插图23 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/adce1f0e3ccb4fde986610fdaa54a8eb.png)
![[git] MacBook 安装git插图25 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/6d5f5cd4b41d4a0a916380da337ed7a8.png)
![[git] MacBook 安装git插图27 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/0004357265bb404084685a6d6a50ca96.png)
![[git] MacBook 安装git插图29 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/8f89d52fa717453fb36058bdc51288c5.png)
![[git] MacBook 安装git插图31 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/6a3774a6f5a744eaa55eb1445b21d2c2.png)
![[git] MacBook 安装git插图33 在这里插入图片描述](https://i-blog.csdnimg.cn/direct/d54d9daa41df45e983b38b9611f047b5.png)