github ssh配置
1) 创建github账户
2) 安装git
3) 配置账号信息
git config --global user.name 用户名
git config --global user.email 邮箱
ssh相关配置
查看是否已经存在ssh key
打开git bash
$ ls -la ~/.ssh
# Lists the files in your .ssh directory, if they exist
1) 生成ssh私钥和公钥
$ ssh-keygen -t rsa -b 4096 -C "你的github邮箱地址"
这里选择免密登录(密码为空),直接回车即可
2) 上传ssh公钥
拷贝id_rsa.pub中的内容
$ ls -a ~/.ssh
./ ../ id_rsa id_rsa.pub
$ cat ~/.ssh/id_rsa.pub


3) 验证是否配置成功
$ ssh -T git@github.com
然后出现以下信息:
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Hi 你的github账号用户名! You've successfully authenticated, but GitHub does not provide shell access.
在github上新建代码仓库


创建本地仓库,将本地仓库和远程仓库关联,上传同步代码
$ mkdir test
$ cd test/
$ git init
Initialized empty Git repository in F:/Workspace/github/test/.git/
$ echo "# test " >> README.md
$ git add README.md
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory.
$ git commit -m "add README.md"
[master (root-commit) f68019b] add README.md
1 file changed, 1 insertion(+)
create mode 100644 README.md
$ git remote add origin https://github.com/yourusername/test.git
$ git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 227 bytes | 113.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote: https://github.com/yourusername/test/pull/new/master
remote:
To https://github.com/yourusername/test.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
github上删除仓库


相关命令
修改对私钥进行加密的密码
$ ssh-keygen -p
手动启动ssh-agent
# start the ssh-agent in the background
eval $(ssh-agent -s)
Agent pid 59566
ssh-add
ssh-add 私钥文件全路径[例如: ~/.ssh/id_rsa]

浙公网安备 33010602011771号