During the last year I’ve been using Sublime Text editor for all of my new text-writing activities.
During the last year I’ve been actively using the version control system Git for our O’Reilly book project.
During the last I’ve been using GitHub hosting for my public projects.
Here’s the problem. Say, you’re a like me – a technical person producing IT content in Sublime Text publishing it on Github. Now imagine, you’re not like me – you have a mistress, and one day you wrote her a love letter using Sublime Text editor. Do you want the content of this letter to become publicly available on GitHub? If you do, stop reading. Now.
Here’s the privacy hole. Sublime Text editor creates a file with the name extension .sublime-workspace. I don’t know all details about what Sublime creators were planning to store there, but it stores unsaved buffers, and I was surprised to see there some texts that were not meant to be public. But it was available to the entire world on GitHub along with my other stuff! Open your .sublime-workspace and let me know if found some surprises there.
To fix this, you need to do the following steps (to the best of my knowledge).
1. Add the line *.sublime-workspace to the .gitignore file in your git repository. The .gitignore is a hidden file, where you can list all the files that should be ignored by Git in future commits.
2. Remove the existing sublime-workspaces file from your Git repository by issuing the following command:
git rm –cached YourFileName.sublime-workspace.
3. Run git filter-branch to remove this file from the history of all branches as described here.
3. Commit and push the changes to Github as usual.
If you’re new to Git and GitHub, you can watch our Introduction to Git video.
Here comes the bad news. Since Git is a distributed version control system, people who forked or cloned your Github repo can enjoy (and sell to the yellow press) that bloody letter you wrote to the mistress. Back to CVS!
3 thoughts on “Preventing Sublime Text leaks in Git”
I’m using Sublime 3, but can’t see this .sublime-workspace file in my home folder… May be that depends on it’s settings?
1. You need to create a Sublime project to see this file (Project -> Save Project As…).
2. It should appear in the root directory of your project, not in the home folder.
To prevent this kind of situation, I also use to save all my Sublime Text projects in a separate folder.