安装git
绑定用户
1.直接在桌面上点击右键,或者点击开始按钮找到Git Bash
2.git config --global user.name "yangdongMC"
git config --global user.email "15967115901m0@sina.cn"
设置SSK密钥
1.检查是否存在ssk(Git Bash中查看)
cd ~/.ssh
ls
如果返回了三个文件,则密钥已经存在了,
2.没有则设置密钥
$ ssh-keygen -t rsa -C "15967115901m0@sina.cn"
3.查看
C:\Users\Administrator.ssh\id_rsa.pub
在guthub上配置密钥
1.将id_rsa.pub中的key粘贴到这里,就好了开始向github上提交文件
1.准备一个本地仓库(文件夹),我这里是准备把darkseer-admin这个文件夹传上去
2.对应的在github远程上,也要创建一个文件夹来接受darkseer-admin,两个文件夹不一定要相同,下面是我在github上创建的一个文件夹,
准备工作就绪,开始操作命令行,进行提交
1.创建一个本地的提交仓库,执行后会在根目录创建一个.git 文件夹
git init
2.提交单个文件,或者根目录下所有的文件
git add 单个文件名
git add .
3.本次提交的注释说明
git commit -m "first commit"
——-完成以上三步如下:
4.连接远程的github仓库
git remote add origin https://github.com/yangdongMC/darkseer-admin.git
5.执行上传命令,这里我没有切换其他分支,使用默认的master分支
git push origin master
———会让你输入之前绑定的邮箱名和密码,如下:
/*error1:问题来了,大致意思是要先执行git pull **/
6.顺意执行他的提示
git pull
/*error2:问题来了,大致意思是要本地与远程建立关联 git branch –set-upstream-to=origin/ master**/
7.接着顺意执行他的提示,关联起来
git branch --set-upstream-to=origin/master
———执行完,如下:
8.关联起来后继续执行提交
git push origin master
/*error3:问题来了,大致意思是当前分支背后了,git pull 推前了**/To https://github.com/yangdongMC/darkseer-admin.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/yangdongMC/darkseer-admin.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.
9.然后我又git pull 了一下,挂了,都无法退出,在根目录重新打开git Bash,提交命令又来了一遍
———注意在:连接远程的github仓库
git remote add origin https://github.com/yangdongMC/darkseer-admin.git
会提示
$ git remote add origin https://github.com/yangdongMC/wanda-admin
fatal: remote origin already exists.
9.1.解决上述问题,执行
git remote rm origin
9.2.再执行一下下面的
$ git remote add origin https://github.com/yangdongMC/darkseer-admin.git
9.3.最后提交一下
git push origin master
———————-终于ok了
———————-远程github仓库
新遇问题:
上图表示在合并中LICENSE文件冲突,需要手动解决再提交
解决后:
git add LICENSE
git commit -m “解决冲突”