基础使用
- 确定安装git
- 登录github
- 找到settings
- 点击SSH and GPG keys
- 跟随generating SSH keys 去做
- 点击Generating a new SSH key and adding it to the ssh-agent查看如何(这部只用于电脑没有ssh key的情况,一台电脑一个key就够了,可以对应无数多个仓库)
-
命令行生成秘钥和公钥:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- 返回终端找到~/.ssh 目录下有其中.pub是公钥,cat id_rsa.pub 将字符串复制到github创建ssh key那块,然后起名字最好是自己电脑的型号(多个电脑虚拟机好分辨)
- 测试是否可以连接上远程github(github找到Testing your SSH connection)
测试可否连接远程github
ssh -T git@github.com
10.成功后说明可以远程连接了
11.
git config --global user.name 你的英文名
git config --global user.email 你的邮箱
git config --global push.default matching
git config --global core.quotepath false
git config --global core.editor "vim"
这五个设置是好习惯!!!!
本地git使用
进入工程文件夹!!!
进入工程文件夹!!!
进入工程文件夹!!!
进入工程文件夹!!!
- git init
- git add 文件
- git status -sb
- git commit -m "说明文字"
- git status -sb
上传github仓库
- 登录github
- 创建仓库,设置名字,点创建
- 之后github官方就会有命令可以操作
问题
最容易出现的问题:
ssh: Could not resolve hostname ssh.github.com: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
这个时候我是把我的DNS修改了,之后就成功了
-
OpenDNS
-
208.67.222.222
-
208.67.220.220
-
GoogleDNS
-
8.8.8.8
-
8.8.4.4