Answer the question
In order to leave comments, you need to log in
How can I remove a folder from the repository starting from the Nth commit using the command (I added the folder, but did not push it)?
Hello. I found this command online:
git filter-branch --force --index-filter "git rm -r --cached --ignore-unmatch BIG/DIR" --prune-empty --tag-name-filter cat -- --all
Answer the question
In order to leave comments, you need to log in
In order not to execute commands that are incomprehensible to you, just remember a simple sequence in this case:
1. accidentally added something to git, committed
2. to remove random files from the repository, you just need to delete these files (transfer temporarily somewhere from the repository) and immediately commit the changes
3. add the file/folder to gitignore, commit
4. return the old location to the file/folder, it will not be included in the commit anymore. In
total, you should get 2 commits for fixing, the first one deletes the files, the second one adds them to gitignor. If at the first point you have already pushed the changes to the remote repository, then after step 3 push again and that's it.
Perhaps you accidentally committed a file containing a password and now want to make your project public, for example, to remove the passwords.txt file from your entire history, you can use the --tree-filter option of the filter-branch command:
https://git-scm.com/book/ru/v2/%D0%98%D0%BD%D1%81%...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question