git说明

git commit -m换行说明:

先输入第一个引号,按Enter即可换行,完成后再补齐后面的引号

// 步骤一: 输入第一行
git commit -m "1. 第一行

// 步骤二: 按Enter 输入第二行
git commit -m "1. 第一行
2. 第二行

// 步骤三: 输入完毕,补齐引号,提交!
git commit -m "1. 第一行
2. 第二行"



git修改远程仓库地址 方法有三种:

1.修改命令

git remote origin set-url [url]

2.先删后加

git remote rm origin
git remote add origin [url]

3.直接修改config文件

 


 

一台电脑,添加多个gitee地址

2. 生成多个 ssh key

2.1. 操作步骤

# 需要管理几个账号就生成几次,请使用实际邮箱地址替换 ${emailAddress}
$ ssh-keygen -t rsa -C "${emailAddress}"
# 提示输入 id_rsa 文件的保存位置
Enter file in which to save the key (.../.ssh/id_rsa):
$ ${emailName}
# 提示输入密码(直接回车)
Enter passphrase (empty for no passphrase):
$
# 提示再次输入密码(再次回车)
Enter same passphrase again:
$

2.2. 实际操作演示

# 1. 生成 account_1@qq.com 的 ssh key
$ ssh-keygen -t rsa -C "account_1@qq.com"
Enter file in which to save the key (.../.ssh/id_rsa):
$ account_1
Enter passphrase (empty for no passphrase):
$
Enter same passphrase again:
$

# 2. 生成 account_2@qq.com 的 ssh key
$ ssh-keygen -t rsa -C "account_2@qq.com"
Enter file in which to save the key (.../.ssh/id_rsa):
$ account_2
Enter passphrase (empty for no passphrase):
$
Enter same passphrase again:
$

3. 创建并配置 config 文件

3.1. 创建 config 文件

文件在 ~/.ssh 下

# 创建 config 文件夹
$ touch ~/.ssh/config

3.2. 编辑 ~/.ssh/config 文件

向其中加入如下内容:

# account_1(account_1@qq.com)
        Host account_1.gitee.com
        HostName gitee.com
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/account_1
        User account_1
        
# account_2(account_2@qq.com)
        Host account_2.gitee.com
        HostName gitee.com
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/account_2
        User account_2

4. 部署 ssh key

参见其他部署 ssh key 的教程

5. 使用


# 原命令
$ git clone git@gitee.com:${username}/${projectName}.git
# 新命令(假如是 account_1@qq.com 的项目)
$ git clone git@account_1.gitee.com:${username}/${projectName}.git
 
原文地址:https://www.cnblogs.com/hmms/p/11935901.html