1、安装
1、1 使用yum安装的
命令:$ yum install git git-gui
2 生成密钥对,使用ssh-keygen方法
ssh-keygen -t [rsa|dsa],将会生成密钥文件和私钥文件 id_rsa,id_rsa.pub或id_dsa,id_dsa.pub
3 、将生成的公钥复制到github.com中的SSHKEY中
$mkdir .ssh
$cd .ssh/
$ssh -keygen -t rsa -C 'qq.com'
如果出现产生的ssh-key无效的错误,请改为一行行的复制公钥内容,注意不要将空格,换行符等复制进来。
特别注意第一个字符不要漏了。
4、登录github。打开setting->SSH keys,点击右上角 New SSH key,把生成好的公钥id_rsa.pub放进 key输入框中,再为当前的key起一个title来区分每个key。
5、测试
将key添加之后,我们测试下能否链接到github。
命令:$ ssh [email protected]
看是否有这些内容出现:
6、设置
为了联系,可以填写你的一些信息
命令:$ git config --global user.name "your name"
$ git config --global user.email "your email"
7、提交
git clone ‘git@地址’
cd 仓库名
mkdir AA #创建文件夹,将要提交的文件放在此文件夹下
cd AA 的上一层目录
git add *
git commit -m ‘注释’
git push -u origin master
常见错误
1、ssh连接服务器错误
ssh连接远程服务器报错connection to ip地址 port 22:Broken pipe
解决:ssh -o ServerAliveInterval = 60 user@sshserver
user指git用户名 sshserver指报错ip地址
2、git 添加文件错误
git add * 命令报错
ubuntu@ip123~/ft$ git add *
The following paths are ignored by one of your .gitignore files:
__pycache__
Use -f if you really want to add them.
解决:ubuntu@ip-123:~/ft$ git add -f xx.txt #强制添加文件