Syncing Obsidian to Android via Termux and Git

I working on a mission where I'm going to treat my phone as a primary computing device with a terminal environment, a concept I call the Mobputer. To make this work for writing, my notes must be more than disconnected files on a phone. They need to live in a system that syncs across environments.

I built a setup relying on a GitHub repository, Termux as the terminal environment on Android, Obsidian (using Obsidian Sync or SyncThing) for cross-device syncing and the Obsidian Git plugin to handle version control directly inside the editor.

Preparing the Environment

The first step is structural: separating personal configuration from actual content so the writing environment remains consistent everywhere.

On the desktop setup, I prevented Obsidian’s internal configuration from leaking into version control by ignoring the .obsidian folder.

echo ".obsidian" >> .gitignore

This appends the .obsidian directory to the Git ignore list. This folder holds UI preferences, plugin states, and workspace layouts. Syncing this between vastly different devices creates conflicts.

Next, I handled the actual file synchronization. I opened my repository as a vault and created a new remote vault in Obsidian Sync. I chose encryption, but the important part is including all file types and plugins. This allows the mobile environment to mirror the desktop setup without manual reconstruction.

On the Android side, I prepared Termux to make the system portable. I initialized storage access and installed Git along with essential utilities.

termux-setup-storage

The first command prompts Android to grant Termux access to the shared internal storage.

pkg install git termux-exec -y

The second installs Git and termux-exec, which ensures commands execute correctly in the Android environment.

I configured Git to avoid authentication prompts during my workflow.

git config --global credential.helper store

This tells Git to save authentication credentials locally. Since the phone is already encrypted and physically secured, this safely eliminates the need to type a personal access token on every sync.

Connecting Mobile to the System

I needed to connect two existing environments: Obsidian on my phone and my Git repository. The goal was to make them recognize each other without breaking Obsidian's internal file management. Sync brings the files over, but Git tracking requires the hidden .git folder which sync services often mishandle or ignore.

Inside Obsidian on mobile, I connected to my remote vault and pointed it to a folder inside internal storage.

/Documents/XYZ

To establish Git history, I opened Termux and cloned the repository into a temporary location. This step exists solely to retrieve the .git folder.

cd /storage/shared/Documents/

git clone https://github.com/user/xyz.git

This navigates to the shared Android documents folder and downloads a fresh copy of the remote repository into a temporary directory.

Once cloned, I extracted the Git metadata and injected it into my synced vault directory.

cp -r xyz/.git ./XYZ/

cp xyz/.gitignore ./XYZ/

These commands copy the hidden version control folder and the ignore rules from the temporary clone into the live Obsidian vault (XYZ). The temporary clone can be deleted afterward.

I verified the connection by running a pull inside the vault.

cd ./XYZ

git pull

This navigates into the live vault and tests the connection to GitHub, ensuring the newly injected .git folder recognizes the remote origin.

Since Git sometimes does not trust the directory ownership on Android, I explicitly marked it as safe.

git config --global --add safe.directory /storage/shared/Documents/XYZ

Android file system ownership models trigger Git security warnings. This command forces Git to ignore the ownership mismatch and operate inside the vault anyway.

Authentication relies on a GitHub personal access token (Classic) instead of a password.

I also ensured the repository state was clean. If Git incorrectly flagged files as deleted due to Android file system quirks, I restored the working tree.

git status

git restore .

git status

The first status check often shows files as deleted because Git on Termux has not fully indexed the synced files. Running restore . forces Git to align its index with the actual files sitting in the directory, and the final status confirms the working tree is clean.

Git operates quietly in the background, tracking everything.

How I Use It

Inside Obsidian on my phone, the Obsidian Git plugin is the only interface I touch. I set it up once with my GitHub identity and token, and it tracks my writing automatically.

I open a new note and write. Everything syncs in the background. A quick status check through Termux or the Obsidian Git command palette confirms everything is tracked properly.

Once the first commit and push succeed, the notes are versioned, portable, and recoverable.

This infrastructure layer allows my writing to exist independently of any single app or device. Obsidian acts as the editor, Git preserves the history, and mobile access via Termux turns the entire setup into a system I carry everywhere.