Ask any note-taking enthusiast about their favorite app, and the name Obsidian is bound to pop up in the conversation every now and again. In addition to its vast plugin collection, Obsidian includes a ton of tools to organize your notes and customize every aspect of the note-taking app. Plus, it’s compatible with multiple backup options, so you don’t have to worry about losing access to your precious notes.

But have you ever wanted to self-host Obsidian on your local server and sync your files to a private Git server? If this unhinged idea sounds fun, you'll love my guide on building a robust knowledge base with Git and Obsidian.

Deploying an Obsidian container

With the Docker community designing fun, practical, and (downright) unhinged container images, it shouldn’t come as a surprise that you can host Obsidian inside a containerized environment. We’ll go with the Obsidian image developed by LinuxServer, which relies on KasmVNC to help you access the note-taking app from any device on your local network. Assuming you're using a Linux system for the Obsidian server,

  1. Open the terminal application included with your distro.
  2. Use the nano text editor to create and open a docker-compose.yml file.
    sudo nano docker-compose.yml
  3. Open the Docker Hub page of LinuxServer’s Obsidian image and copy the text under the docker-compose section into the yml file you created earlier.
  4. Modify the /path/to/config variable with an actual directory on your system.
  5. Press Ctrl+X followed by Y and Enter to save the changes and exit the docker-compose.yml file.
  6. Execute the following command to get the Obsidian instance up and running.
    sudo docker compose up -d
  7. Once Docker has pulled the necessary images and deployed the Obsidian instance, you can access the web UI by typing the IP address of your system followed by a colon (:) and port number 3000 into your favorite web browser.
  8. Click on the Create button, choose a Vault Name and hit Create a second time to open the Obsidian dashboard.

Installing the Git plugin

Now that you’ve set up Obsidian, you’ll need the Git plugin to sync your notes with a private GitHub repository. To do so,

  1. Click on the Settings icon in the bottom left corner of the screen, navigate to the Community plugins from the left, and press the Turn on community packages button.
  2. Tap the Browse button adjacent to the Community packages.
  3. Use the Search bar to find the Git plugin by Vinzent, (Denis Olehov) and hit the Install button after selecting it.
  4. Wait for Obsidian to install the plugin before tapping Enable.

Connecting the Git plugin with a private GitHub repository

Finally, it’s time to pair the self-hosted Obsidian server with your GitHub repo. To do so,

  1. Head to your GitHub account and create a Private repository for your Obsidian notes.
  2. Click on your Profile Picture and select Settings inside the pop-up menu.
  3. Scroll down and choose Developer settings.
  4. Select Tokens (classic) and click on Generate New Token (Classic).
  5. Pick the necessary permissions, hit the Generate token button, and copy the token created by GitHub somewhere safe.
  6. Switch to the Obsidian web UI and create a new folder for the files you wish to sync with your GitHub repo.
  7. Tap Ctrl+P to open the command palette and select Git: Clone an existing repo.
  8. Enter the access token followed by an @ symbol and the GitHub link to your private repository. The overall format should resemble this:
    https://access_token@github-repo
    https://ghp_DQw5oPUX40hVBRzxasffdTnbL5VZT1osP1C@github.com/Ayush-Tech-User/obsidian.git
    You can use the Clipboard option inside KasaVNC to quickly paste your link instead of manually typing all the characters.
  9. Enter the Obsidian folder you created earlier as the note directory and leave the Depth field empty.
  10. Reboot your Obsidian container using the docker restart command.
    sudo docker restart obsidian
  11. Click on the Settings icon, switch to the Git tab, and enter your GitHub Username and Email under the Author Details section.
  12. Create a new file inside the shared folder and tap the Commit and Sync button to copy the file to your private Git repo.

Sync Obsidian files like a pro madman with Git

If you’ve performed all the steps correctly, the committed and pushed notifications will appear inside Obsidian, and the Git plugin will sync your notes with the GitHub repository. I recommend specifying a duration for the Auto commit-and-sync option in Git settings to automatically save changes to your private repo. I’ll admit that it’s not the most efficient way to safeguard your notes, but it’s a lot cooler than your average backup method.

👁 Running a BookStack server
4 of the best tools to document your home-lab operations

Struggling to keep track of your home lab experiments? These apps can help you out!