总结自网络
先导知识: ![在这里插入图片描述](https://img-blog.csdnimg.cn/7e28f69483c94112b19a7324cbd0d787.png) 工作区–暂存区–仓库区----远程仓库区 ![在这里插入图片描述](https://img-blog.csdnimg.cn/51eef9b79c924738a6a60db2399f8913.png)
一.git项目搭建
1.本地仓库搭建(本地新建文件夹,生成本地仓库) ![在这里插入图片描述](https://img-blog.csdnimg.cn/f77449947d814dffa11210a141153c8c.png) 2.远程仓库克隆 将远程服务器上的仓库复制一份到本地, 仓库的地址 ![在这里插入图片描述](https://img-blog.csdnimg.cn/f6e7d29ccc7e477f8cd8b186d12279a9.png)
$ git clone [url] https://gitee.com/woaichirourou/drug-mall.git
二. git使用流程
$ git status
采用先建远程仓库,克隆到本地仓库
1.马云新建远程仓库
![在这里插入图片描述](https://img-blog.csdnimg.cn/db6374301321472aacb6887286386580.png) ![在这里插入图片描述](https://img-blog.csdnimg.cn/e05edd0a0e5b47e8a835a192046f88a3.png) ![在这里插入图片描述](https://img-blog.csdnimg.cn/6c886911871649fdb3d521f7b4ec1e90.png) 克隆到本地,文件一模一样
2. idea操作
2.1 新建项目,绑定git
- 将上面克隆到本地的git文件目录拷贝到项目文件中
![在这里插入图片描述](https://img-blog.csdnimg.cn/f5d2c7832cf744168ecf30332f46c63a.png) ![在这里插入图片描述](https://img-blog.csdnimg.cn/c3a9c41d7d6c42238e23741e3416389d.png) 剪切本地仓库的文件夹到项目文件中 ![在这里插入图片描述](https://img-blog.csdnimg.cn/42752f4abfa348dfa64c7f7571b17251.png)
idea变化 ![在这里插入图片描述](https://img-blog.csdnimg.cn/f6a37186dae2416b92479ce987394eae.png)
2.2 修改文件,使用IDEA操作git
- 添加到暂存区 $ git add .
- commit提交 $ git commit -m “第一次提交”
- push到远程仓库 $ git push
一开始有一些文件是红色的 ![在这里插入图片描述](https://img-blog.csdnimg.cn/2517968271714e85a50df3961088116b.png) 点击右上角commit
![在这里插入图片描述](https://img-blog.csdnimg.cn/8a04d63847674b03af609ebfc96232d3.png) 添加后变绿
(或者手动命令行 $ git add. )
若单个文件修改了,则右键->git -> add ![在这里插入图片描述](https://img-blog.csdnimg.cn/58f3fe08abee4a49bcacd1d5cd5916d5.png) 提交成功,点击左下角 Version-Control ![在这里插入图片描述](https://img-blog.csdnimg.cn/fe4c561f928b4d5c9f9d7bd42f7f8885.png) 此时只到了本地仓库区,下面要push到远程
注意使用命令行若出现
'git' 不是内部或外部命令,也不是可运行的程序或批处理文件。
需要配置git的环境变量,环境变量就是使git命令能够全局使用
找到git的安装目录下的bin文件,用户变量和系统变量的path都新建一个 ![在这里插入图片描述](https://img-blog.csdnimg.cn/12c5d77ee2d64d47a5081bc7a71fea01.png) ![在这里插入图片描述](https://img-blog.csdnimg.cn/3419db5498a646299767125f129ebafa.png) 这个时候百度刷新,远程仓库就有了 ![在这里插入图片描述](https://img-blog.csdnimg.cn/108acfe292ea4a56911f7164044bd4a4.png)
2.3 git分支
![在这里插入图片描述](https://img-blog.csdnimg.cn/b5c82cda0f134ebdb4cd0ee9ad746780.png)
![在这里插入图片描述](https://img-blog.csdnimg.cn/ceeca80036204a0ca40c9e9f2ca20a34.png)
git checkout -b gpf origin/gpf
![在这里插入图片描述](https://img-blog.csdnimg.cn/ba3c7ff7bc5f43c8abb23f65cce5c691.png)
git push --set-upstream origin 分支名
git命令:https://blog.csdn.net/qq_38349413/article/details/124604427
|