Author -  Sai gowtham

View the recent commit history in Git

In this tutorial, we are going to learn about how to view the commit history in git with the help of examples.

Viewing commit history

To view the commit history in Git, we can use the git log command followed by the -p flag.

-p means patch where it shows the difference occur in each commit.

Here is an example:

git log -p

when you run the above command, It will display the commit history in reverse chronological order(last to first) similar to the below output

commit a6537cdc1d033d3853829e6baa194df44b750422 (HEAD -> master)
Author: saigowthamr <saigowthamr@gmail.com>
Date:   Wed Feb 25 05:09:03 2020 +0530

    changed data

diff --git a/n.js b/n.js
index 05c9bb3..710f139 100644
--- a/n.js
+++ b/n.js
@@ -6,3 +6,8 @@ dgf
 New line
+
+decodeURI
+
+
+hello
\ No newline at end of file

commit fb2h5925202199ff6dc62763303c9aa33ff8d3d9
Author: saigowthamr <saigowthamr@gmail.com>
:

If you want to view the number of insertions and deletions in each commit use --stat option.

git log --stat

Output:

commit a6537c241d033d3853829e6baa294df14b750422 (HEAD -> master)
Author: saigowthamr <saigowthamr@gmail.com>
Date:   Wed Feb 25 05:09:03 2020 +0530

    fixed typos

 n.js | 5 +++++
 1 file changed, 5 insertions(+)

commit fb265925t402999ff6zc62763343c9aa33ff8d3d9
Author: saigowthamr <saigowthamr@gmail.com>
Date:   Tue Feb 25 05:04:05 2020 +0530

    added some text

 n.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

commit df92196v4d6f4680b191204b70c7db96cfa60d47
Author: saigowthamr <saigowthamr@gmail.com>
Date:   Tue Feb 18 05:01:40 2020 +0530

    added numbers

Viewing commit history of an individual file

To view the commit history of an individual file we need to use the git log command followed by the -p flag and ‘name of the file’.

git log -p yourfilename

Viewing the list of modified files

The --name-only flag helps to view the list of modified files in each commit.

Example:

git log --name-only

Output:

commit a6537c1c1dnj3d3853829e6baa294df14b750422 (HEAD -> master)
Author: saigowthamr <saigowthamr@gmail.com>
Date:   Wed Feb 25 05:09:03 2020 +0530

    errors fixed

app.js

commit fb26592520299cdff6dc62763343c9aa33ff8d3d9
Author: saigowthamr <saigowthamr@gmail.com>
Date:   Tue Feb 25 05:04:05 2020 +0530

   added head tags

app.js
index.html

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY