Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 850
R C Avatar asked Jun 05 '12 19:06

R C


People also ask

Can you clear a git log?

basically what you want to do is delete the file containing the logs which is your ". git" file. rm -rf . git // this is saying remove recursively the git file.

How do I remove something from git log?

To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.

How do I clean up commit history?

Steps to get to a clean commit history:understand rebase and replace pulling remote changes with rebase to remove merge commits on your working branch. use fast-forward or squash merging option when adding your changes to the target branch. use atomic commits — learn how to amend, squash or restructure your commits.


1 Answers

      ______________________________    . \  | / .
     /                            / \     \ \ / /
    |                            | ==========  - -    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.
like image 150
larsks Avatar answered Sep 20 '22 19:09

larsks