![]() ![]() But you want to get rid of that file, and you have the power to do it. Īn interactive rebase lets you go back in history and redo commits, as if they were correct in the first place. java -jar bfg.jar -delete-files $FILE -no-blob-protection. Normally BFG Repo-Cleaner protects your most recent commit, but if you know what you are doing (and you know, right?) then you give it the option -no-blob-protection, which is sort of like saying, do what I want and don't protect me from mistakes. This tool claims to work 10-720x faster than any other method, but you cannot specify a subdirectory, it will delete all files with the same name in any directory. Scenario 2: the file is further down in the history and you have not yet pushed Solution 1: BFG Repo-Cleanerĭownload 'BFG Repo-Cleaner' here. ![]() The git reflog expire and git gc commands force a garbage collection, to keep the file from dangling somewhere in your repository. Git reflog expire -expire=now -all & git gc -prune=now -aggressive gitignore, to prevent it from being added by accident again. ![]() You want to keep the file locallyĪmend the last commit to remove the file from the repository, and add it to. Scenario 1: the file is in the last commit and you have not yet pushed 1. If your code (with unwanted file) is already out in the open (GitHub, BitBucket.) then you might be out of luck. But if you work in a team then first talk it over with them. If you're a single developer, just go for it. If you have already pushed your changes, then things might become complicated. They are written for Linux, but should work on OS X and even on Windows if you use Git Bash. Hereby an overview per scenario in increasing order of complexity.Īll of these methods assume that you are familiar with console commands. Depending on where the file is, you can use several methods. Simply git rm passwords.txt won't do it, as the file will still be there in all previous commits. Do you want to be the person who committed AWS keys to a public GitHub repository, only to find out 24 hours later that ~USD2000 has been spent mining bitcoins? Several methods The goal is to completely wipe a file out of existence in a Git repository, to cover all tracks of your horrible mistake. Have you already committed an SSH private key, a password file or a config file with sensitive data to your repository before? In case you did not, I would recommend to first try this out before you continue reading this blogpost.įor the rest of us: DON'T PANIC! Take a deep breath, get up from your desk, walk around for a few minutes. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |