多分支同时开发过程中git使用

233 阅读1分钟

前言

Git,日常工作中使用版本控制系统,你可能用过,也知道基础知识,比如git add,git commit,git push,git pull。嗯... 但今天我说点别的,比较杂乱的随记。

stash缓存代码

场景

同一个时间 段 同时开发同个项目里的不同的需求,经常需要 切换分支,但是你这部分代码还没开发完,不想提交,也不想用commit,怎么办? 尤其是同时提测阶段,个人习惯会喜欢用stash来做暂存,等更紧急的任务解决完再切换回来恢复暂存的代码

git status 查看修改

image.png

git stash 做缓存

  • 模拟git checkout 之前 做一次stash
  • git stash后 再 git status :查看本地 是否有待commit的代码
  • git stash list :查看stash 操作的是否成功

image.png

git stash pop 恢复之前暂存代码

image.png

git stash save "添加备注,方便查找"

  • 例子:git stash save '第一个测试111111'
  • 查看缓存结果git stash list

image.png

git stash apply 应用某个存储

实际业务场景 害怕 自己缓存列表多 害怕pop了 不该pop的部分 先 给stash 加备注 然后 apply 应用目标缓存。 image.png

git stash clear 清空缓存列表

  • 清除后 git stash list查看 清空结果

image.png