If you use both Google Chrome browser and its upstream development version, Chromium, on the same machine, you may, like me, want a way to sync your Bookmarks between the two locally, without using some third party cloud sync/backup service.
Well there’s an easy way to do this with a software version control control system like Git, Mercurial, Subversion, etc. I use Linux and Git, but this technique should work on any operating system with any version control system.
There are three pertinent filesystem locations - the Chrome Bookmarks file, the Chromium Bookmarks file, and the Git repo you will create to sync the two:
1 2 3
- Create a bare git repository that will serve as the parent or hub for syncing the two Bookmarks files.
- Initialize a child git repository in each of Chrome and Chromium’s settings directories where the Bookmarks file resides.
Primary browser (Chromium, for this example):
- Set remote origin to the hub repo for both.
- Include a
.gitignorefile that ignores everything except ‘Bookmarks’ and ‘.gitignore’.
1 2 3
- Add, Commit, and Push the Bookmarks repo of your primary browser (say Chromium). Pull the repo to your secondary browser (Chrome in this case).
Primary browser (Chromium for this example):
1 2 3 4
Secondary browser (Chrome for this example)
1 2 3 4
- The tricky part - Chrome and Chromium both calculate the hash of the Bookmark file every time it is changed from within the browser, and add that hash as the first entry in the top of the Bookmarks file. It is included in every new hash as well. If that recorded hash does not match the calculated hash when Chrome/ium starts up, it will assume the file is corrupt and fall back to Bookmarks.bak instead. Hence, you have to be careful when synching - you can never merge the remote hub repo if you have made changes locally, or it will cause the calculated hash to diverge from the recorded one, and Chrome/ium will think the file is corrupt and will ignore it in favor of the older Bookmarks.bak. The simple solution is to make sure that when you add new bookmarks to one, you also pull those changes into the other browser before adding new bookmarks to the other.
I’m working on a post-commit hook that will automatically do this, but not done yet.
Done. Now whenever you add bookmarks to one browser, keep the parent repo updated with:
1 2 3 4 5
And finally just remember to also do a
git pull origin master from the other browser before adding any new bookmarks to it as well.