阅读目录:
1. 下载并安装Git 2.8.x版本
2. 配置Git 2.8.x
3. 上传项目
4.关于报错解决
5.注意事项以及说明
前提:一定先建立好远程仓,如下图所示
1. 下载并安装Git 2.8.x
1.1 下载
下载网址如下:https://git-for-windows.github.io/
1.2 安装
双击该软件完成,具体细节暂时省略。。。
2. 配置Git 2.8.x
2.1 配置用户名(提交时会引用)
鼠标右击项目,点击 git bash here
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission
$ git config --global user.name "Your Name" //举个栗子:git config --global user.name "loubobooo"
2.2 配置邮箱(提交时会引用)
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission $ git config --global user.email "Your Email Address" //举个栗子:git config --global user.email "[email protected]"
3. 上传项目
3.1 初始化git仓
扫描二维码关注公众号,回复:
129157 查看本文章
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission $ git init
3.2 添加本地文件到暂存区(三种方式)
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission $ git add --all
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission $ git add
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission $ git add README.md
3.3 添加本地文件到版本库
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission $ git commit -m "你的注释"
3.4 添加远程仓库地址
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission $ git remote add origin https://gitee.com/xxx/xxx.git //举个栗子:git remote add origin https://gitee.com/loubobooo/mmall.git
3.5 向远程仓库推送代码(这里没有使用ssh秘钥方式提交)
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission $ git push origin master
4. 关于报错解决
如果出现以下报错:
error: failed to push some refs to 'xxx(远程仓)'
原因是:远程仓中的README.md不在本地代码目录中
可以通过如下命令进行代码合并【注:pull=fetch+merge]
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission $ git pull --rebase origin master
执行上面代码后可以看到本地代码库中多了README.md文件
再执行语句
loubobooo@loubobooo MINGW64 /d/ideaIU-15.0.6/workspace/IdeaProjects/permission $ git push -u origin master