Take the 2-minute tour ×

How do you display the commit content specified with SHA-1 in a Ruby on Rails application?

share|improve this question
add comment

3 Answers

As a disclaimer I'm not sure if this is an answer to your question but I'll give you what I know:

In the console (folder for your project, obviously), you can get a list of the files you have changed and their status for your upcoming commit with:

git status

To get a readout of the exact code changes, you can type into the console:


Hope that helps!

share|improve this answer
thanks fot gitk it seems well, but this I wanted.I am writing code in ruby on rails and I need to display content of some revision, for example I have file aaa.txt with content 123, I'll commit it, then I'll do a revision of file aaa.txt, new content will be 123456, i commit it, Now I need to write code in ruby using for example grit to show conntent of some commit when from view I'll get sha of this commit, when I'll get sha of first commit I have to show content "123" –  kazko Nov 19 '11 at 20:20
add comment

There's a good library for this. Include it in your gemfile and look at the docs for how to implement.


share|improve this answer
add comment

Just use grit:

require 'grit'

repo = Grit::Repo.new(path_to_repo)

Then just play with the commit object returned. Check out http://grit.rubyforge.com/. If you want to see the changed files by that commit you can do

commit.diffs.each {|d| puts d.a_path || d.b_path }
share|improve this answer
add comment

Your Answer


