Git操作
一、Git结合Idea实现将本地仓库上传到远程仓库
1.使用Idea提交代码
1.1在 idea 中配置 git 路径
![](https://gitee.com/happy-prince/my_-images/raw/master/Git/1.jpg)
1.2在远程仓库上创建仓库
创建本地仓库
![](https://gitee.com/happy-prince/my_-images/raw/master/Git/2.jpg)
1.3****将项目添加到缓存
![](https://gitee.com/happy-prince/my_-images/raw/master/Git/3.jpg)
161.4****提交项目
![](https://gitee.com/happy-prince/my_-images/raw/master/Git/4.jpg)
1.5****提交并上传
![](https://gitee.com/happy-prince/my_-images/raw/master/Git/5.jpg)
1.6****添加远程仓库地址
![](https://gitee.com/happy-prince/my_-images/raw/master/Git/6.jpg)
1.7****查看上传状态
![](https://gitee.com/happy-prince/my_-images/raw/master/Git/7.jpg)
如果上传时出现 Push rejected: Push to origin/master was rejected
解决办法:
1.选择你要上传代码的文件夹,鼠标右键 git Bash Here
2.输入下面两行命令
git pull origin master --allow-unrelated-histories--
把远程仓库中的内容 pull 到本地工作目录
git push -u origin master -f --
在 pull 下来的项目中做修改,通过以上命令 push 到远程 仓库了