bash - Git: Show content of file as it will look like after committing -
after reading git pre-commit hook : changed/added files, following question arose:
given have file both staged , unstaged changes, how can display preview of file's contents after staging?
example:
echo "foo" >> file git add file echo "bar" >> file wanted output:
[previous contents of file] foo
use : prefix access objects in current index (staged not yet commited).
git show :file see gitrevisions (emphasis mine):
<rev>:<path>, e.g. head:readme, :readme, master:./readmea suffix
:followed path names blob or tree @ given path in tree-ish object named part before colon.:path(with empty part before colon) special case of syntax described next: content recorded in index @ given path.
Comments
Post a Comment