How to clean up Git and Repo invalid code in Linux system

  
                

The Linux system code reference code repository will become larger and larger during use, and some invalid files are accumulated. All of the Linux Git and Repo code should be cleaned up after a while. So how to clean up Git and Repo invalid code in Linux system?

manually clean

If your code repository problem is relatively small, only a few documents should not be submitted, it can directly use this method to clean up

approximately The process is as follows:

First Git garbage collection:

git gc --auto

Next, check the Git repository footprint:

$ du -hs . Git/objects45M .git/objects

Then find out files of a certain size in history, and finally delete and commit in history. If you are interested in manually processing this process, you can refer to the link behind the article.

Related commands:

Clean up files in history:

git filter-branch --force --index-filter ‘git rm --cached - -ignore-unmatch ****/nohup.out’ --prune-empty --tag-name-filter cat -- --all

git filter-branch --index-filter ‘git rm --cached --ignore-unmatch ****/nohup.out’ HEAD

git for-each-ref --format=“%(refname)” refs/original/

Copyright © Windows knowledge All Rights Reserved