IDEA 2021.3配置
参见 https://blog.csdn.net/qq_44866828/article/details/115304268
插件推荐:
- maven helper
- sequence diagram 生成对象间的调用关系
选中方法名 - sequence diagram - 时序图选中任一部分 - go to source 跳转
可remove class / method,时序图可保存
Maven配置
Mac安装参见 https://blog.csdn.net/weixin_44141870/article/details/109908580
Maven参数说明 参见 https://juejin.cn/post/7010941177482444808
Git使用
Mac安装参见 https://www.jianshu.com/p/7edb6b838a2e
官方文档 https://git-scm.com/docs
书 https://git-scm.com/book/en/v2
演练 https://learngitbranching.js.org/?locale=zh_CN
工具推荐sourceTree https://www.sourcetreeapp.com/
- 安装homebrew
/usr/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew -v
- 安装git
brew install git
git --version
- 配置ssh
// 配置git用户信息
git config --global user.name "username"
git config --global user.email "emailAddress"
// 生成ssh
ssh-keygen -t rsa -C "emailAddress"
// 查看ssh 复制emailAddress之前的部分
cat .ssh/id_rsa.pub
登录Github - Setttings - SSH keys - Add key 粘贴
- git 分支模型
参见https://segmentfault.com/a/1190000040348946
master | 核心主干 最稳定 随时可release,只能从其他分支合入,不能在其上做提交 |
---|---|
develop | 开发主干 稳定的、最新的分支,合并其他分支 如feature |
feature | 新功能分支 使用频率最高,开发测试稳定后合入develop做集成测试,稳定后从develop 拉出release分支 |
release | 发布分支 新版本发布,只做bugfix |
hotfix | 紧急修复分支,bug修复 |
- 常用指令:
查看状态git status
查看日志git log branchName
查看提交历史git show 提交文件的id值
查看暂存区中的改动git diff --cached
查看工作区中的改动git diff
⚠️ Git允许工作区和暂存区的改动同时存在,即git status
出现两种状态 (git commit
只提交暂存区修改)
拉取远程更新git pull
,git fetch
对比参见 https://juejin.cn/post/6844903921794859021
git branch -a
查看所有分支,-r
查看远程分支
git commit -m 'msg'
必须写提交信息
cat .git/HEAD
查看head的指向
git push branchName
推送更新
代码合入:merge:位于master分支git merge branchName
rebase:位于个人分支git rebase master
IDEA terminal 使用 Git
- 拉取项目
git clone repoSSH
- 导入模块 file - new - module from existing sources - pom.xml
- 编译 / 跳过test编译
mvn clean install -DskipTests
- 更新 maven依赖
- 导包 target目录 - generated sources - mark directory as - sources root
- 创建分支做修改
git branch newBranchName
git checkout newBranchName
git checkout -b newBranchName
- 查看分支
// 本地分支
git branch -a
// 远程分支
git branch -r
- master 合入当前分支
// 位于当前分支
git rebase master
- 拉取远程更新
git checkout master
git pull
或 git - update project - 刷新maven
⚠️ 切换分支前要保证工作区干净(add 但未 commit)否则无法切换分支
// 隐藏未commit的修改
git stash
// 使重新出现
git stash pop
- 代码merge
保证编译全部通过 - 拉取远程更新 - 当前分支合入 - 解决冲突 - 分支合入
git add .
git commit -m 'msg'
git push origin branchName
// HEAD指向要合入的分支
git push origin HEAD
⚠️游离状态的 HEAD
head指向了某个具体的提交记录而不是分支名,此时 Checkout 切到其他节点则提交很可能丢失
解决:基于当前节点创建分支 git checkout -b branchName
,head回到非游离态
源码阅读
参见 https://zhuanlan.zhihu.com/p/441178281
常用快捷键 Mac
查看作者:代码行右键 - annotate with git blame - 关闭:右键 - close annotations
转到源码:command+左键
查看类的层次结构(显示抽象类、接口的实现):类名上 control+h
查看方法在何处被调用过:方法名上 control + option + h
查看某个方法/类的实现类:在方法名/类名上 command + Alt + B/鼠标左键
查看类的结构:structure 或 command+7
检索:当前页面搜索 command + f
全局检索 两次shift
全局检索类/文件 command+o
查找字符串、指定文件 Ctrl+Shift+F