git常用指令备忘录

show

  • 查看指定 commit 的某个文件内容: git show <commit>:<file>
  • 查看指定 stash 的某个文件内容: git show stash@{<id>}:<file>

stash

  • 保存特定文件到 stash 中: git stash -- <file>

rebase

  • 合并多个commit: git rebase -i HEAD~<n> 要保留的使用pick, 要合并的使用squash

checkout

  • 还原文件内容: git checkout <commit> -- <file>
  • 从stash中还原特定文件内容: git checkout stash@{<id>} -- <file>
  • 处理冲突时:
    • git checkout --ours <file>: 在stash冲突时不使用stash的内容;在merge冲突时不使用feature分支的内容;在rebase冲突时不使用rebase修改的内容
    • git checkout --theirs <file>: 在stash冲突时使用stash的内容;在merge冲突时使用feature分支的内容;在rebase冲突时使用rebase修改的内容



Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • Qwen3-Next:下一代MoE模型架构解析
  • 端侧LLM硬件系列(一):内存带宽
  • CoreML踩坑记:慎用Conv1D
  • 深入 gpt-oss-20b 架构:MNN 移动端性能实践
  • 混元端侧模型分析