Migrating My Obsidian Vault From iCloud to Git

I have been using Obsidian for note-taking for quite some time now, having switched from Logseq. Both are quite similar in functionality to me, but I much prefer Obsidian’s “File over app” approach. In case the product get discontinued, I still get to keep my notes because, in the end, they are .md files.

I use iCloud to back up my Obsidian notes and i has worked very well so far. Never encounter any out-of-sync issue but now since I can’t use iCloud on my work machine, I need a new alternative. I considered paying for Obsidian Sync, but I already have too many subscriptions. So, a Git-based setup it is.

The migrations process are seamless. Here are the steps I took to migrate my Obsidian Vault to Git:

  1. Copy Obsidian folder
    Copy my Obsidian folder to ~/Developer/obsidian , out of iCloud folder.
  2. Initialize local & remote git repository
    Initialized git repository in my local vault. Then, I created a remote repository on Github and added it as origin.
    > cd ~/Developer/obsidian  
    > git init~  
    > git remote add origin git@github.com:username/repo.git`
  3. Configure .gitignore
    Added .gitignore to exclude unnecessary files. While some suggest to ignore the .obsidian folder, I included it so that my configurations and plugins are synchronized across devices. I also ignore work/ folder to exclude any sensitive info.
  4. Commit and push
    > git commit -am "Initial commit"  
    > git push -u origin main`
  5. Install git plugin in Obsidian
    Obsidian git plugin
  6. Configure the plugin
    I set the Vault Backup interval to 60 minutes (might change in the future), set the sync method as Merge and to automatically pull updates on startup.
  7. Clone the repo on work machine
    Once done, I cloned the repo on my work machine, copied over any existing notes I had on my work machine and deleted the old vault.

This setup has been working well for me for a few weeks. Hopefully, I will never encounter any issues.

Some Notes While Setting Up My New MacBook

I finally did it—I bought a MacBook! I’ve worked as a software engineer for almost nine years but never had my own personal machine. I have a very old MacBook Air, but that was different. It was kind of a gift. Still have it stored somewhere, but it’s pretty much useless. I can’t upgrade the macOS anymore and the battery requires servicing.

I always wanted to buy one, but I kept putting the idea aside because every company I worked for always provided one and based on my observations, most of my friends or colleagues who have both a personal and a company-provided MacBook rarely use theirs. I figured the same thing would happen if I bought one.

Anyway, my current company’s device policy is very strict (banking industry), which makes me feel anxious about using it for personal stuff, so I figured it’s probably a good time for me to get one. So here I am.

I jot down some of my thoughts while setting up my MacBook:

  • I find it crazy how my dotfiles configuration still works fine after all these years, but some installation steps are out of order. For example, to install SwiftLint, I need to have Xcode installed. I probably should fix this and turn it into a single bash script. Someday soon.
  • I can’t praise asdf enough. I installed Python, Ruby, and Node with it. Convenient.
  • 14-inch MacBook Pro is nice to hold and carry. I always got issued a 16-inch MacBook Pro at work, so while the large screen density is impressive, I really don’t like how heavy it is.
  • Space Black is beautiful. However, I don’t really like! how the power adapter is white while everything else is mostly black. I’m not the only one who complained about it, by the way.
  • I still can’t decide which code editor theme to use. I’ve been using Dracula theme for years, but I feel like trying out other themes, especially high-contrast themes. Currently, I’m trying out the Catpuccin Mocha theme.
  • There are applications specified in my Brewfile that I’m not using anymore. I took the liberty to clean it up.
  • I am planning to buy a Proxyman license next. I use it at work and really like how convenient it is. It definitely helps boost my development speed.

So far, it’s been a pleasant experience. I guess I still got the hedonistic pleasure from buying expensive things. I just hope that Apple won’t release the MacBook M4 Pro tonight.

My own MacBook

Installing Python 3.12.0 with asdf

I tried installing Python on my work machine last week using asdf.

The steps to install it are easy. All I had to do was add the Python plugin and run asdf install

> asdf plugin-add python # add python plugin
> asdf install python 3.12.0

It was not exactly a smooth process. I got the following error:

python-build 3.12.0 /Users/xxx/.asdf/installs/python/3.12.0
python-build: use openssl@3 from homebrew
python-build: use readline from homebrew
Downloading Python-3.12.0.tar.xz...
-> https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz
Installing Python-3.12.0...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/xxx/.asdf/installs/python/3.12.0/lib/python3.12/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'
WARNING: The Python lzma extension was not compiled. Missing the lzma lib?
Installed Python-3.12.0 to /Users/xxx/.asdf/installs/python/3.12.0
asdf: Warn: You have configured asdf to preserve downloaded files (with always_keep_download=yes or --keep-download). But
asdf: Warn: the current plugin (python) does not support that. Downloaded files will not be preserved.

After some googling, I found out that I needed to have xz installed. Yes, that xz. I was a bit worried but it seems like running brew install xz will install the older version, 5.4.6 which is free from the backdoor.

Once I had xz installed I just had to run the following commands to install Python on my work machine:

> asdf install python 3.12.0
> asdf global python 3.12.0 # will set 3.12.0 as the global default

How to Stash Only Staged Changes in Git

Normally, when I need to stash my code changes, I run git stash. This command stashes all my changes in the Git staging area. Then, I manage my stashes (pop, apply, drop) using Sublime Merge. I am pretty comfortable with this workflow.

However, while working on a task recently, I needed to quickly switch branches to check an issue for a colleague. Normally, I would run git stash before changing branches, but this time I didn’t want to stash all the changes in the staging area. Instead, I wanted to stash only the staged files and leave the unstaged files as they were.

Luckily, there’s a command for this:

git stash -- $(git diff --staged --name-only)

Let’s break it down:

  • git diff --staged --name-only outputs a list of files with changes in the staging area
  • git stash -- $() stashes only the files listed by the previous command.
  • This ensures that only the staged changes are stashed, while any unstaged changes remain in the staging area.

Pretty neat, right? I hope this tip helps!

My Essentials Tools

I am going to hand over my work device this Friday since it will be my last day here in Boost. I thought it would be interesting to document the collection of tools I have used over the years. Many of these have been already documented in my dotfiles repo but still, I just want to share it here for fun.

Selected CLI tools

I think I have countless CLI apps installed for development and most of it are pretty common to have, like git, mysql or too low-level (coreutils, cmake) so I will exclude those. Here is the list of tools that I like and somewhat uncommon, most of which are installed using brew.

  • ack: the better grep
  • antigen: plugin manager for zsh. It’s similar to oh-my-zsh, but it has faster startup times.
  • asdf: to manage multiple versions of ruby, node, python, etc. I don’t have to install and remember how to use nvm or rbenv anymore.
  • carthage: dependency manager for iOS, similar to Cocoapods. Installed it since my current company uses it, but I don’t really prefer it.
  • diff-so-fancy: to prettify git diff output in terminal.
  • chisel: Collection of LLDB commands to help debug iOS apps. Created by the Facebook team.
  • gh: CLI to interact with GitHub API. I use it to quickly create or delete remote repo from terminal.
  • goreleaser: to package go app as binaries.
  • mkcert: to create local self-signed certificates. I usually use it when I need to create certs during app development.
  • quicktype: to convert JSON to model quickly. Rarely used it since I mostly use their app instead.
  • tree: to quickly inspect the directory structure from CLI
  • swiftlint: linter for Swift to enforce coding style guidelines.
  • vim: :q!
  • xcbeautify to prettify the xcodebuild logs. Installed when I was working on setting up iOS CI/CD pipelines.
  • xcodes: to install Xcode from CLI. Friends don’t let friends installed Xcode through AppStore. It helps me too easily switch between multiple Xcodes versions too.
  • youtube-dl: to download videos
  • z: to easily jump around between directories.

Noteworthy Apps

Beyond CLI tools, here are some applications that have been integral to my development workflow:

  • Xcode : the main tool I use for my day-to-day development. I have multiple Xcode installed in fact. Xcode-15.0.0, Xcode-14.3.1 and Xcode-14.1.0. All installed using xcodes .
  • Copilot for Xcode: 3rd-party app that I use to have GitHub Copilot on Xcode. It’s not as good as Copilot on VSCode, but it works.
  • Android Studio: official IDE for Android. I use it sometimes when I feel like learning Android or Flutter development.
  • VSCode: code editor I use for anything besides Swift.
  • Ulysses: app focus on writing. Bought a 1-year subscription when I first published a post on my SubStack account, SwiftByte. 🙈
  • Raycast: Spotlight on steroids. I used to use Alfred 3, but I don’t really feel like paying for the upgrades, so I tried RayCast. Fell in love with it right away.
  • Figma: the native app for Figma. I used it whenever I want to hyper-focus on building UIs.
  • DBeaver: database browser. Can support multiple types of DB like mysql, postgresql, sqlite etc through plugins. Installed using Cask
  • DB Browser for sqlite: similar to DBeaver. I use it whenever I need to inspect local database in mobile apps since it has a much simpler interface. Installed using Cask.
  • Logseq: a note-taking app or personal knowledge base? I don’t know, but I used it for quick note-taking and also document my learnings. Though I have since migrated to Obsidian. Installed using Cask.
  • Obsidian: somewhat similar to Logseq.
  • NetNewsWire: RSS reader.
  • Arc: the better Chrome browser. Although I feel like migrating to Safari soon since it already supports multiple profiles.
  • Deckset: to make pretty presentations using Markdown. Usually, I use this whenever I have a knowledge sharing session.
  • Hammerspoon: macOS automation tools through Lua scripting. I use it to script tiling-window manager and some other stuffs. Installed using Cask.
  • The Unarchiver: for unarchiving any non .zip files. Installed using Cask.
  • ImageOptim: to compress images before uploading it to web. Installed using Cask.
  • Postman: for debugging and testing HTTP requests
  • Apple Developer: honestly, I hate the fact that most of Apple docs are hidden behind WWDC videos.
  • SF Symbols: for inspecting Apple SF Symbols icons.
  • Discord: for chats. I joined programming related groups here.
  • iTerm2: terminal emulator. Just better features compared to stock terminal. Installed using Cask
  • Docker: Don’t really use it that much, but it’s nice to have whenever I want to fire up an instance since most OSS these days provide docker images. Installed using Cask.
  • Dash: API documentation browser. I still have the old version. Planning to upgrade soon.
  • Sublime Merge: git client. I use it together with git CLI. Mostly for resolving conflicts and visualising git tree.
  • Telegram: for chats. Joined a couple of programming related groups here as well. Installed using Cask
  • tomato: my own app. A simple pomodoro app that lives in my menu bar. Installed using Cask.

Others

  • font-iosevka: my favourite monospace fonts. Installed using brew.

These tools have speed up my workflow over the years and made my life easier. I hope you find some of these useful.