R C
R C

Reputation: 248

Clear git log file

I want to clear the git log files so that the command git log returns nothing. Is this possible? Is this recommended?

Upvotes: 13

Views: 41147

Answers (3)

Alex de Kruijff
Alex de Kruijff

Reputation: 255

You might be looking for:

git reflog expire --expire=now --all
git gc --aggressive --prune=all

The first line will prune all unreachable reflogs. The second line will do a number of housekeeping tasks, such as compressing file revisions and removing unreachable objects.

Upvotes: 7

mayaki ujeh
mayaki ujeh

Reputation: 1

basically what you want to do is delete the file containing the logs which is your ".git" file.

  1. rm -rf .git // this is saying remove recursively the git file.
  2. git init // this is making the folder a git repo again.

Upvotes: 0

larsks
larsks

Reputation: 312018

      ______________________________    . \  | / .
     /                            / \     \ \ / /
    |                            | ==========  - -    WARNING!
     \____________________________\_/     / / \ \
  ______________________________      \  | / | \      THIS WILL DESTROY
 /                            / \     \ \ / /.   .    YOUR REPOSITORY!
|                            | ==========  - -
 \____________________________\_/     / / \ \    /
      ______________________________   / |\  | /  .
     /                            / \     \ \ / /
    |                            | ==========  -  - -
     \____________________________\_/     / / \ \
                                        .  / | \  .

git log displays the change history of your project. If you really want to discard all of that history, you could...

rm -rf .git
git init

...but there are a relatively small number of situations where that really makes sense.

There aren't any "git log files" that git uses to produce this output; it is iterating over the database of objects that form the history of your project. If you delete the .git directory like this, there's no going back:

  • You will not be able to retrieve previous versions of files from the repository;
  • You will not be able to see how files have changed over time;
  • You will not be able to restore a file you have accidentally deleted.

Upvotes: 26

Related Questions