How to view the full git log?

You can use “git log” to view the complete log of commits without code changes. Use “git log -p” to include code changes. Below are three variations in a real-world code on an existing system and their outputs.

repoone has a branch called main, as shown. “git log” would show all the commits along with their details except for code changes.

~/repoone$ git log
commit 4632c0d520218e90d6f6645e80773d9b7e8ab0f7 (HEAD -> main, origin/maincopy)
Author: Code Version Master <codeversionmaster@gmail.com>
Date:   Sat Sep 24 13:04:50 2022 +0000

    Adding empty directory

commit 908d6ac779f38123751ddd70d6107bb43cc832a1 (origin/main, origin/HEAD)
Author: paperspace <Code Version Master>
Date:   Sat Sep 10 05:15:28 2022 +0000

    Third commit in main

commit 42296d0c4e8f0a61f3948dab14f1518a1a05b348
Author: paperspace <Code Version Master>
Date:   Sat Sep 10 05:14:40 2022 +0000

    Second commit in main

commit 453424edeed5c7c668cf7ce5d9f3b4ccb9aa566e
Author: paperspace <Code Version Master>
Date:   Sun Sep 4 17:43:08 2022 +0000

    This is first commit

commit 2673111c4500cd406b587c1c067c9bfbae707e86
Author: codeversionmaster <112749588+codeversionmaster@users.noreply.github.com>
Date:   Sat Sep 3 12:58:29 2022 +0530

    Initial commit

“git log -p” would show all the commits, including code changes in the main branch.

~/repoone$ git log -p
commit 4632c0d520218e90d6f6645e80773d9b7e8ab0f7 (HEAD -> main, origin/maincopy)
Author: Code Version Master <codeversionmaster@gmail.com>
Date:   Sat Sep 24 13:04:50 2022 +0000

    Adding empty directory

diff --git a/dirtwo/.gitignore b/dirtwo/.gitignore
new file mode 100644
index 0000000..5e7d273
--- /dev/null
+++ b/dirtwo/.gitignore
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore

commit 908d6ac779f38123751ddd70d6107bb43cc832a1 (origin/main, origin/HEAD)
Author: paperspace <Code Version Master>
Date:   Sat Sep 10 05:15:28 2022 +0000

    Third commit in main

diff --git a/filefive b/filefive
new file mode 100644
index 0000000..e69de29
diff --git a/filesix b/filesix
new file mode 100644
index 0000000..e69de29

commit 42296d0c4e8f0a61f3948dab14f1518a1a05b348
Author: paperspace <Code Version Master>
Date:   Sat Sep 10 05:14:40 2022 +0000

    Second commit in main

diff --git a/filefour b/filefour
new file mode 100644
index 0000000..e69de29
diff --git a/filethree b/filethree
new file mode 100644
index 0000000..e69de29

commit 453424edeed5c7c668cf7ce5d9f3b4ccb9aa566e
Author: paperspace <Code Version Master>
Date:   Sun Sep 4 17:43:08 2022 +0000

    This is first commit

diff --git a/dirone/fileone b/dirone/fileone
new file mode 100644
index 0000000..c2a1599
--- /dev/null
+++ b/dirone/fileone
@@ -0,0 +1 @@
+this is file one
diff --git a/filetwo b/filetwo
new file mode 100644
index 0000000..f8156fa
--- /dev/null
+++ b/filetwo
@@ -0,0 +1 @@
+this is file two

commit 2673111c4500cd406b587c1c067c9bfbae707e86
Author: codeversionmaster <112749588+codeversionmaster@users.noreply.github.com>
Date:   Sat Sep 3 12:58:29 2022 +0530

    Initial commit

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..45508cf
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# repoone
\ No newline at end of file

You can use “- n” to restrict the number of commits to number n. For example, using “git log -p -2”, as shown, would display all the details of each commit, including code changes. But it would show only the information for the top two commits.

~/repoone$ git log -p -2
commit 4632c0d520218e90d6f6645e80773d9b7e8ab0f7 (HEAD -> main, origin/maincopy)
Author: Code Version Master <codeversionmaster@gmail.com>
Date:   Sat Sep 24 13:04:50 2022 +0000

    Adding empty directory

diff --git a/dirtwo/.gitignore b/dirtwo/.gitignore
new file mode 100644
index 0000000..5e7d273
--- /dev/null
+++ b/dirtwo/.gitignore
@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore

commit 908d6ac779f38123751ddd70d6107bb43cc832a1 (origin/main, origin/HEAD)
Author: paperspace <Code Version Master>
Date:   Sat Sep 10 05:15:28 2022 +0000

    Third commit in main

diff --git a/filefive b/filefive
new file mode 100644
index 0000000..e69de29
diff --git a/filesix b/filesix
new file mode 100644
index 0000000..e69de29