"Nuke-level options" for the first time using git: filter-branch delete files from the repository

Source: Internet
Author: User

When I looked at Pro Git, I was frightened by the author's nickname "Nuke-Class option", so I never dared to try it curiously. Nuclear bombs, with the right to the infinite, with the wrong destructive power infinite!

But today, I had to use it because I wanted to put some of my original code on GitHub and go public. Since did not want to public before, to upload only found that can not upload more than 50M files.

Toss for a while, still can't upload, so, the whole command came out:

git filter-branch--tree-filter'RM-RF Files_to_remove'--prune-empty-f HEAD--all

The command is quite complicated, so I am in a clone out of the warehouse first try to run. First explain the following parameters:

    • --tree-filterRepresents a list of modified files.
    • --msg-filterRepresents the modification of the submission information, the original submission is read from the standard input, the new submission output to the standard output.
    • --prune-emptyIndicates that if the modified commit is empty, discard it. In a trial run I found that although the file was deleted, but also left an empty commit, the next man document, found this option.
    • -fis to ignore the backup. Without this option, the second time you run this command, you'll get an error, meaning that git did the last backup, and now you have to run it to get rid of the last backup.
    • --allis for all branches.

Try running a few times, see more than 40 commits are rewritten, and then check to see that the files to be deleted are indeed deleted. So happily to GitHub to build a new warehouse, and uploaded.

Toss it over, I like git more:-)

"Nuke-level options" for the first time using git: filter-branch delete files from the repository

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.