Git mistakenly commits a file that you do not want to commit, and the method you want to remove from the repository

Source: Internet
Author: User
Tags commit
git mistakenly commits a file that you do not want to commit, and the method you want to remove from the repository Example: Remove Lunch_history from the repository

Git filter-branch–tree-filter "rm-f lunch_history" HEAD
Will output the following information:
Rewrite 48A23742F0B5C35127DAA40A1303C2AF7976BAAC (29/29)
Ref ' refs/heads/new_bianjb_7300 ' was rewritten
This means: The new repository has been rewritten with a 40-bit hash value. You also need to remove the backup from the rewrite process:
git update-ref-d refs/original/refs/heads/new_bianjb_7300 48A23742F0B5C35127DAA40A1303C2AF7976BAAC
Otherwise, the next action will also cause an error:
Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with-f
At this point, do the following:
Delete the. Git/refs/original Directory
This directory is a temporary file that you can delete

Reference: http://www.cnblogs.com/RichardLee/articles/2938382.html
Reference: http://www.davidverhasselt.com/git-how-to-remove-your-password-from-a-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.