Thursday, June 15, 2023

Setting Up Remote Git Sync In Working Copy on macOS

Working Copy is an iOS git client app. It has a good text editor and a pleasant UI. Since it is a git client it can sync with remote git servers. Here I will decribe how to sync within internal network running git server on macOS.

1. Install Simple Git Server on macOS.
2. Under repositories create a new repository. I use Working Copy mainly for journalling. So I will create a repo named journal.git. Use .git extension ticked.
3. Start the git server. It will show two URLs. One with IP and other with local domain name. Use the domain name URL as it's constant.
4. Checkout the created repo under mac.
$ git clone git://ataraxia.local/journal.git
5. Open Working Copy on iPhone and create a new directory. Let's call personal. We cannot move repositories to new directory once cloned. Once in the directory, tap on the plus button and choose clone repository. For the url give git://ataraxia.local/journal.git and tap clone.
6. Add a file sync-test.txt to test the syncing. Commit the file with push radio button enabled. This will sync the changes to remote.
7. Go to macOS Terminal and run
$ git pull
This will show output like below.
jsloop@ataraxia journal % git pull
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 220 bytes | 220.00 KiB/s, done.
From git://ataraxia.local/journal
 * [new branch]      main       -> origin/main
Your configuration specifies to merge with the ref 'refs/heads/master'
from the remote, but no such ref was fetched.
Here we can see that the repo fetched all remote branches which is main but did not checkout the fetched branch. Let's checkout the main branch.
jsloop@ataraxia journal % git checkout main
branch 'main' set up to track 'origin/main'.
Switched to a new branch 'main'
Now that the files are checked out, use ls to view the synced files. Any changes made from the macOS and sycned with remote will appear on Working Copy on pull. I use terminal and Fork app for git GUI on macOS.

This gives us a fully locally synced git repository. After finding Obsidian not working for me, I have moved all files to Working Copy and now uses it for my journal. I write journals in plain text files, so this setup works well.