混帐:显示文件的内容,它看起来就像犯后 [英] Git: Show content of file as it will look like after committing

查看:109
本文介绍了混帐:显示文件的内容,它看起来就像犯后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ P $后的P-commit钩子:改变/添加文件,以下问题出现了:

由于我有两个文件被演出和不分级的变化,我怎么能分期后显示的文件内容的preVIEW?

示例:

 回声富>>文件
混帐添加文件
回声酒吧>>文件

诚征输出:

  [文件previous内容]


解决方案

使用 preFIX访问当前索引中的对象(上演,但尚未COMMITED )。

 混帐显示:文件

请参阅 gitrevisions (重点煤矿):


 <&转GT;:<路径>中例如HEAD:README,:README,师傅:./自述

一个后缀后跟路径名在由冒号前的部分指定的树杂交对象的给定路径上的BLOB或树。 :路径(用冒号前的空白部分),下面描述的语法的一个特例:在给定的路径记录在索引中的内容


After reading Git pre-commit hook : changed/added files, the following question arose:

Given I have a file with both staged and unstaged changes, how can I display a preview of the file's contents after staging?

Example:

echo "foo" >> file
git add file
echo "bar" >> file

Wanted output:

[previous contents of file]
foo

解决方案

Use the : prefix to access objects in the current index (staged but not yet commited).

git show :file

See gitrevisions (emphasis mine):

<rev>:<path>, e.g. HEAD:README, :README, master:./README

A suffix : followed by a path names the blob or tree at the given path in the tree-ish object named by the part before the colon. :path (with an empty part before the colon) is a special case of the syntax described next: content recorded in the index at the given path.

这篇关于混帐:显示文件的内容,它看起来就像犯后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆