# 利用SSH使git和码云同时推送 **Repository Path**: uxzhen/synchro ## Basic Information - **Project Name**: 利用SSH使git和码云同时推送 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-27 - **Last Updated**: 2022-11-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 步骤1.检查是否已经存在SSH Key 打开电脑终端,输入以下命令:ls -al ~/.ssh 会出现两种情况 步骤2. 生成/设置SSH Key 继续上一步可能出现的情况 (1)情况一:终端出现文件id_rsa.pub 或 id_dsa.pub,则表示该电脑已经存在SSH Key,此时可继续输入命令:pbcopy < ~/.ssh/id_rsa.pub 这样你需要的SSH Key 就已经复制到粘贴板上了,然后进行步骤3 (2)情况二:终端未出现id_rsa.pub 或 id_dsa.pub文件,表示该电脑还没有配置SSH Key,此时需要输入命令:ssh-keygen -t rsa -C "your_email@example.com" (注意,这里的 your_email@example.com 是你自己的邮箱,选一般的常用的邮箱即可,笔者当时用的是腾讯企业邮箱,就出现了一点小问题,所以不常用的邮箱一般不推荐) 默认会在相应路径下(/your_home_path)生成id_rsa和id_rsa.pub两个文件,此时终端会显示: Generating public/private rsa key pair. Enter file in which to save the key (/your_home_path/.ssh/id_rsa): 连续回车即可,也可能会让你输入密码,密码就是你的开机密码 此时再输入命令:ls -al ~/.ssh 就会出现id_rsa.pub 和 id_dsa.pub两个文件,然后重复情况一的步骤即输入以下命令再进行步骤3即可:pbcopy < ~/.ssh/id_rsa.pub 首先创建SSH,然后同时添加到git和码云,然后把库克隆下来(主库用哪个同步的时候就会同步哪个); 打开隐藏.get文件夹,然后打开config文件。 把这段 ``` [remote "origin"] url = git@github.com:uxzhen/xxx.git fetch = +refs/heads/*:refs/remotes/origin/* ``` 改成这样 ``` [remote "origin"] url = git@github.com:uxzhen/T1_Admin.git url = git@gitee.com:uxzhen/xxx.git fetch = +refs/heads/*:refs/remotes/origin/* ```