通过 ssh git 私有项目

通过 ssh git 私有项目

通过 ssh git 私有项目

1. 通过 ssh-keygen 创建一个 key, 备注信息一定写你帐户的邮箱, 按提示完成即可.

ssh-keygen -t rsa -b 4096 -C "[email protected]"

2. 将公匙 ( 就是 id_rsa.pub 文件 ) 文本信息添加到帐户里面.

3. 编辑 ~/.ssh/config 添加以下内容:

host github.com
 HostName github.com
 IdentityFile ~/.ssh/id_rsa_github
 User git

4. 测试密匙可用, 如果能显示你的用户名表示连接可用.

ssh -T [email protected]

5. clone

git clone [email protected]:username/repo.git

6. push

git push

7. 需要先配置你的邮箱及用户名

git config --global user.name "John Doe"
git config --global user.email [email protected]

8. 添加/删除子模块(别人的或是另一个项目)到项目上

### 添加
git submodule add <url> <repo_name>
    
### 删除
git rm --cached <repo_name>

-= 完 =-