配置
- 配置必要信息
git config --global user.email "you@example.com"
git config --global user.name "youname"
- 远程分支配置
git remote -v #查看远程地址
git remote rm origin #删除远程地址
git remote add origin git@192.168.1.9:Me/Work.git #增加远程地址
基础指令
git add . #增加目录下所有文件
git commit -m "提交文件" #提交到本地层酷
git pull #拉取远程代码并合并
git push #推送本地仓到远程服务器
生成ssh-key
- 生成key进行免密推送
ssh-keygen -t rsa -C "you@example.com"
注:一直回撤不用输入
- 查看密码
cat ~/.ssh/id_rsa.pub
- SSH免密登录
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.9
问题解决
fatal: index-pack failed
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
fatal: refusing to merge unrelated histories
$ git pull
fatal: refusing to merge unrelated histories
- 解决方式:操作命令后面加 –allow-unrelated-histories
git merge master --allow-unrelated-histories
git pull --allow-unrelated-histories