![](https://img-blog.csdnimg.cn/img_convert/1d6a86ddfe8a4e09320cf01f20a23d1a.png)
概念:
![](https://img-blog.csdnimg.cn/img_convert/efe32c76d1453d7b1f8921417491a80b.png)
![](https://img-blog.csdnimg.cn/img_convert/3a0becba8413827ef2ed98b847cdbdd9.png)
Git命令:
全局设置:
git config --global user.name "用户名"
git config --golbal user.email "邮箱地址"
git config --list
获取Git仓库:
二选一,仓库不能嵌套
git init # 初始化本地仓库
git clone 远程仓库地址 # 克隆到本地
本地仓库操作:
git status # 查看文件状态
git add # 将文件的修改加入暂存区
git reset # 将暂存区文件取消暂存或切换到指定版本
git commit # 将暂存区文件修改提交到版本库
git log # 查看日志
远程仓库操作:
git remote # 查看远程仓库
git remote add # 添加远程仓库
git clone # 从远程仓库中克隆
git pull # 从远程仓库中拉取
git push # 推送到远程仓库
![](https://img-blog.csdnimg.cn/img_convert/6c2d1410f9ad12523adec59d184f7d34.png)
分支操作:
git branch # 查看本地分支
git branch [name] # 创建分支
git checkout [name] # 切换分支
git push [shortName] [name] # 推送至远程仓库分支
git merge [name] # 合并分支到当前分支
标签操作:
![](https://img-blog.csdnimg.cn/img_convert/8600010ce797ebebf74479bd74e754b8.png)
git tag # 列出已有标签
git tag [name] # 创建标签
git push [shortName] [name] # 将标签推送至远程库
git checkout -b [branch] [name] # 检出标签
在IDEA中使用Git:
![](https://img-blog.csdnimg.cn/img_convert/362b44a09118dbee039441ce40d9a5ce.png)
本地初始化仓库:
![](https://img-blog.csdnimg.cn/img_convert/ae9189549c77de4a201cdd285b7fe08e.png)
创建了git后,没有添加暂存和提交本地库文件就会变成红色,但是不是报错的意思
从远程仓库克隆:
![](https://img-blog.csdnimg.cn/img_convert/9b0962e44dabfb44ed88f9d5cf517072.png)
将文件加入暂存区:
![](https://img-blog.csdnimg.cn/img_convert/4791022cf66c819e5ce80f5ee75b8101.png)
加入暂存区后文件为绿色
将文件提交到版本库:
![](https://img-blog.csdnimg.cn/img_convert/687f58fb0e22a9f4ec41a272df356722.png)
提交到版本库后文件变黑色(暗色主题下为白色)
快捷提交:
修改后可直接提交,省略添加到暂存区的操作,简化操作
![](https://img-blog.csdnimg.cn/img_convert/d0998a543a9d6ef78e9cceed09c242e0.png)
远程仓库操作:
查看:
![](https://img-blog.csdnimg.cn/img_convert/1c1abf55134cf6c369f6c9ef392fa44f.png)
推送至远程仓库:
![](https://img-blog.csdnimg.cn/img_convert/b283f04fb933388158722e25c0bc5a9b.png)
提交并推送:
![](https://img-blog.csdnimg.cn/img_convert/420cc12d033f8ee42bd6396e66902b5d.png)
从远程仓库拉取:
![](https://img-blog.csdnimg.cn/img_convert/3ec642b78ae2321885736235f5200c32.png)
分支操作:
![](https://img-blog.csdnimg.cn/img_convert/1237611707fbf52b8a0195945c18962a.png)
快捷操作:
![](https://img-blog.csdnimg.cn/img_convert/999e8b323a87b8a27d044d11d4372549.png)