RSS Amplifier

Martin's Blog · Jul 24, 2024

Working with Git on Android

0
Sign in to vote or save

Martin Stemplinger · Martin's Blog

It’s been quite some time since I wrote this post and it’s somewhat outdated so I decided to update it.

Background

I started to use Dendron which is a fantastic knowledge management software based on Visual Studio Code. You write your notes in markdown and store them in so-called ‘vaults’. These can also be git repositories.

After setting it up and working with a growing base of notes I wondered how to best sync this to Dendron across multiple devices (private and work laptop). Thinking of it I realised that this is a problem git can to solve. Hence I moved everything into a private git repo on GitHub.

This way my knowledge base is in sync and current between my work and private laptop.

The missing piece were my mobile devices: an Android phone and tablet.

Turns out there are easy ways to have git on an Android device.

Termux

If you use git chances are you’re comfortable with the Linux commandline. In that case Termux may be a good option. It provides a quite capable Linux environment on a phone or tablet in which you can install git and ssh on it to work with any repo. Due to the way Termux works when you run the first git command you will receive an error message stating something like detected dubious ownership in repository at '/storage/emulated/0/Documents/reponame'.

The error message even tells you how to fix it by running git config --global --add safe.directory /storage/emulated/0/Documents/reponame.

You need to do this just once and from then on git should just work.

A nice addon is the Termux Widget. Once you followed the script directory installation pulling and pushing repos is then just a click away. My simple scripts look like this:

#!/usr/bin/bash
eval $(ssh-agent)
source ~/../usr/bin/source-ssh-agent # path might varied based on your system and brand
cd ~/reponame
git pull

and

#!/usr/bin/bash
eval $(ssh-agent)
source ~/../usr/bin/source-ssh-agent # path might varied based on your system and brand
cd ~/reponame
git add -A
git commit -m "sync from android tablet"
git push

Mgit

The app I use is Mgit and here is how I set it up:

  • install MGit. The version on GooglePlay no longer works on newer versions of Android. Instead install the version available from F-Droid
  • create a new personal access token on GitHub. The reason for this is that I didn’t manage to get ssh keys to work.
  • Add a default folder for your repos as well as your name and email in the MGit settings
  • Clone my private repo. I used the access token instead of a password with my usual userid.

Once this is done the repo is available for any markdown editor that reads the file system. Beside my favourite app Neutrinote I tried Droidedit, Markor and Epsilon which are also great editors.

I no longer use Neutrinote or GitJournal. The former because I couldn’t get it work on Android 11+ and the latter since it quite often had sync issues. Instead I use now the mobile Obsidian client with the Obsidian Dendron Tree plugin. This combination makes for a nice mobile Dendron client.

If you want to follow this route keep in mind that Obsidian is not open source. If you use it for business you will need a license. The way I read it maintaining a personal knowledge base does qualify as personal use so I don’t need a license. While there is a git plugin I don’t use it:

  • The author warns that it’s unstable
  • it doesn’t support ssh which I prefer

Workflow

This is now my workflow which is a basic git workflow:

  • I pull all changes to my device
  • I create, edit and delete notes
  • I commit and push
  • Back in Dendron I run Dendron: Doctor to add the required frontmatter.

Should I replace my Android tablet by an iPad in the future a similar workflow is possible thanks to Working copy as described here

Read the original on mstempl.netlify.app

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.