Git show contents of a commit

In order to see the contents of a commit:

#git show 4f62eae1b

This will print the content of the commit.

If you like to see the parents of a commit you can use ^ (caret sign). If you like see the parent of a parent commit use two of them ^^.

#git show 4f62eae1b^
This will show the parent of this commit.

#git show 4f62eae1b^^
This will show the parent of the parent commit.

It is also possible to use numbers.

#git show 4f62eae1b^2
This is equivalent to
#git show 4f62eae1b^^

Git show contents of current state or HEAD

In order to show the contents of the repository, you can use:

# git ls-tree HEAD
100644 blob 6d50415da79edca233601057a46bbb4d7c20494a HelloWorld.java
100644 blob 323fae03f4606ea9991df8befbb2fca795e648fa foobar

100644 indicates the permissions.
blob is the type of the object.
6d50415da79edca233601057a46bbb4d7c20494a is the object hash.
Then there comes the name of the File.

if you like to see the contents of the blob:

#git cat-file -p 6d50415
public class HelloWorld {

public static void main(String[] args) {
// Prints “Hello, World” to the terminal window.
System.out.println(“Hello, World”);
}

}

jQuery Timeago plugin

In many applications, we display resources creations, modification date time, and many times we need this information in a more readable way to make is easy to grasp, something like, Post created 10 minutes ago, or image uploaded 3 weeks ago.

This information can be generated both on server and client side.

For client side, there is timeago plugin, which is convenient and easy to use.

jQuery timeago plugin

Here is a server side time ago method written in c#.