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:./readme 

a 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

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -