git show命令显示指定文件在某一提交的所有内容

Git 2020-02-16 阅读 233 评论 0

使用 git 的show命令,查看指定的文件,在某个提交历史的完整内容,即使文件在这一 commit 没有修改过。

  • 查看某一提交的 test.php 文件内容。
$ git show c960d4a3:test.php

使用show命令,有点类似 shell 的less命令,输出结果可以分页显示,如果要直接在控制台输出而不分页,可以结合cat

$ git show c960d4a3:test.php | cat
  • 查看主分支的文件内容
$ git show master:test.php
  • 查看分支 delivery 的文件内容
$ git show delivery:test.php
  • 查看分支 delivery 的上一个提交的文件内容
$ git show delivery~:test.php
最后更新 2020-02-16
MIP.watch('startSearch', function (newVal, oldVal) { if(newVal) { var keyword = MIP.getData('keyword'); console.log(keyword); // 替换当前历史记录,新增 MIP.viewer.open('/s/' + keyword, {replace: true}); setTimeout(function () { MIP.setData({startSearch: false}) }, 1000); } }); MIP.watch('goHome', function (newVal, oldVal) { MIP.viewer.open('/', {replace: false}); });