一、使用办法
如果已有先clone
git clone git地址
add .
修改文件后
git commit -m '提交说明'
上传至库文件
git push origin master
可是当你第一次push的时候一般会遇到如下报错:
这种错误的主要原因是你的远程仓库的内容有改动但是你本地并没有拉去最新的代码所以会报错。
$ git push origin master
To https://github.com/yuanchao614/wecoder.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/yuanchao614/wecoder.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方法 首先:
git pull origin master --allow-unrelated-historie
二、设置GIT的全局用户名和邮箱:
git config --global user.name=xxx
git config --global user.email=xxx
设置的账号与邮箱与 git push 没有关系,git push 要求输入的是远程仓库的账号/邮箱以及密码
三、配置github ssh文件 输入:ssh-keygen -t rsa ,连续三次回车(即不做任何输入),结果如下: 
通过结果显示及cat命令查看可知public key存放于id_rsa.pub中
输入:cat id_rsa.pub (去指定目录下)复制所有内容
到github右上角账户管理-Setting下面找到左侧“SSH and GPG keys”菜单,接着点击“Add SSH key”,在”title”栏输入一个自己喜欢的标题,“key”栏中粘贴刚刚复制的公钥内容,最后点击“Add key”按钮。(粘贴时选择为纯文本),最后生成的结果
————————————————
ssh -T git@github.com
显示正确文件为:
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
文章评论