poor content

not useful

useful

very useful

excellent

Rate

git write terminal to file2

January 25, 2022

Alireza Ataei

By: Alireza Ataei

Write git output to file

Reading time: 1 min

    Content List

Write git terminal outputs to file

The simplest solution, which basically writes the output into the given file instead of the terminal:

 

git log > filename.log

 

Let’s dive deeper now.

The previous command, would overwrite the given file if it has been already created and written.

In order to append the new data you can use an extra > char:

 

git log >> filename.log

 

  • ( > ): skips terminal output and writes to the file (overwrite)
    • ( >> ): same as previous one, but appending
  • ( 2> ): only writes the errors in file and prints the normal logs in terminal (overwrite)
    • ( 2>> ): same as previous one, but appending
  • ( &> ): only writes all the logs and errors to the file (overwrite)
    • ( &>> ): same as previous one, but appending
  • ( | tee ): prints everything on terminal, as well as writing logs to file (overwrite)
    • ( tee -a ): same as previous one, but appending
  • ( |& tee ): prints everything on terminal, as well as writing everything to file (overwrite)
    • ( |& tee -a ): same as previous one, but appending

Was this page helpful?

What was the most helpful point of this page for you?

Thanks for your cooperation!

poor content

not useful

useful

very useful

excellent

Comments3

3 responses to “Write git output to file”

Leave a Reply

Your email address will not be published.