I only recently added a .gitignore file to ignore some specific data files in a subdirectory of mine. I’d really like to go back in time and remove them from previous commits/history as well.
Is this easily accomplished? Where/how should I start?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will be a two-step procedure:
Introduce the .gitignore file
For this to work, the early commits are going to have to have your
.gitignorefile. So, you need to:git checkout -b temp $(git rev-list HEAD | tail -1).gitignorefile.git commit --amendRewrite history
Now you can automatically remove these files from all of the branches by this command:
git filter-branch --tree-filter 'git clean -f -X' -- --allThis will rewrite all of your branches to remove ignored files. It may take a while depending on the size of your repository.