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:

  • Google Stitch 体验:解决 CC 写 UI 的痛
  • MNN 任务实测:七个模型,三个梯队
  • MiMo-V2-Pro 测评:同一模型,两种结局
  • 如何设计端侧高性能 Tokenizer?MNN 重构实践与思考
  • MiniMax-M2.7 实测:离 Claude 还有多远?