Search code examples
gitgit-diff

removing the index from git diff logs


diff --git a/sample.py b/sample.py
index ce490c6..2e069ee 100644
--- a/sample.py
+++ b/sample.py
@@ -1,4 +1,6 @@
print("Hello world")
print("Sample project")
print("git log issue")
-print("git log issue demo")
\ No newline at end of file
+print("git log issue demo")
+print("different changes in log")
+print("sample git issues")

I want to remove the first four lines from git logs, which tells about the metadata of diff.


Solution

  • You can easily do it with sed. You can use, git diff | sed -n '5,$p' or more generally
    git diff | sed -n 'm,$p'

    This means that you are saying sed to print from the mth line to the last line of the file and -n is to suppress automatic printing of pattern space.