0

This is the latest commit code change (added text "new line added"). How can I get this text to another temp file?

$ git show
commit c3fc4d58275740e5abc85219d75c2c00f3027a46 (HEAD -> my_branch, origin/my_branch)
Author: ********
Date:   ********

    test

diff --git a/test.txt b/test.txt
new file mode 100644
index 000000000..e833ecb7d
--- /dev/null
+++ b/test.txt
@@ -0,0 +1 @@
+new line added
\ No newline at end of file
LUSeR
  • 1
  • 1
  • 1

1 Answers1

0

Use : git diff | nano temp.txt

git diff shows the changes between the working directory and the index. This shows what has been changed, but is not staged for a commit.

| means the output from the left statement will be the input to the right statement.

nano temp.txt creates a file called temp.txt.

Abanoub Asaad
  • 510
  • 4
  • 14
  • git show | nano temp.txt works but not what I want. This adds other commit information as well to the temp file. I only want the line of code added ("new line added") in my case. – LUSeR May 17 '21 at 16:55
  • Where do you want the file to be saved? – Abanoub Asaad May 17 '21 at 17:02
  • Local directory. Actually I only want the content of file. I will process the content and than delete the temp file. It's ok even if I don't create the temp file. Even if I get the content in the terminal it will be enough. – LUSeR May 17 '21 at 17:18
  • You can process what you want on the file "temp.txt". When you finish, write `rm temp.txt` – Abanoub Asaad May 17 '21 at 17:35
  • I am not able to get only the added code lines. I am getting other commit information with it. – LUSeR May 17 '21 at 17:37