Skip to content

Instantly share code, notes, and snippets.

@apples
Last active September 24, 2023 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apples/2a056545bee75a2e0880610ab09d2429 to your computer and use it in GitHub Desktop.
Save apples/2a056545bee75a2e0880610ab09d2429 to your computer and use it in GitHub Desktop.
A tutorial on setting up the Godot 4.0 editor on Android with Git and Termux.

Godot Editor on Android

Overview

This tutorial is designed to set up a complete Git workflow on Android, complete with LFS, and use it with the Godot editor.

The storage usage is minimal.

Be prepared to get a bit technical. You should be familiar with command line tools, and be comfortable with typing arcane sigils using whatever keyboard you have.

Installing and configuring Termux

Find Termux here: https://termux.dev/en/

Download the latest release of Termux from either the GitHub Releases page or through F-Droid.

Personally, I went the GitHub route. You'll likely need to allow permission to install APKs through whatever browser you used to download it.

Once you've got it installed, open it. You'll be greeted with a pretty barebones terminal.

First, we need to install some packages:

~ $ pkg up # updates your existing packages
~ $ pkg install openssh # needed for SSH authentication
~ $ pkg install git
~ $ pkg install git-lfs # needed for LFS

You may need to progress through several confirmation prompts. If you don't know what you're doing, all I did was hit y on every prompt, and everything seemed to turn out fine.

We also need to tell Termux we want to access the shared storage, so run:

~ $ termux-setup-storage

That will create a directory in your home called storage, which will contain several links to the shared directories on your phone:

~ $ ls storage
dcim  downloads  movies  music  pictures  shared

Deciding where things will go

Now is a good time to decide exactly where you want your Git repositories to be clones to.

If you were to clone a repo into your Termux home dir, it would work, but other Android apps wouldn't be able to access it. This is why we set up the storage directories, as they can be accessed by any apps.

In the storage directory are several links, some of which go directly to specific locations, such as downloads mapping directly to your Downloads folder.

The shared link is special in that it points to the directory which is the root of your device's shared storage, which is typically where the other shared folders are contained.

Personally, I made a directory called shared/Repos, as I didn't want to clutter any of my other folders.

~ $ mkdir storage/shared/Repos

Wherever you decide, remember it for later.

Creating an SSH key for GitHub

I highly recommend using an SSH key, as it will make authenticating with GitHub a lot easier.

If you wish to use password-based authentication, you're on your own.

If you're not quite familiar with using SSH for GitHub, take a look at this: https://docs.github.com/en/authentication/connecting-to-github-with-ssh

First, we need to generate the key:

~ $ ssh-keygen -t ed25519

Personally I didn't bother setting a passphrase.

Next, I used cat to quickly display the public key:

~ $ cat .ssh/id_ed25519.pub

And then manually copy-pasted it over to my browser, when setting up my SSH key in GitHub itself.

If you're not sure how to do that, refer to the docs linked above, or just go here: https://github.com/settings/keys

To test the SSH connection, you can run:

~ $ ssh -T git@github.com
Hi apples! You've successfully authenticated, but GitHub does not provide shell access.

Setting up Git globals

The git setup is very typical.

First, configure your name and GitHub email:

~ $ git config --global user.name Apples
~ $ git config --global user.email 2352020+apples@users.noreply.github.com

Then, assuming you're planning on using Git LFS, you need to "install" it:

~ $ git lfs install
Updated Git hooks.
Git LFS initialized.

Making a space for your gitdirs

So, there's a slight problem: If you were to attempt to clone a git repo anywhere inside of your shared directory, then the LFS hooks will fail to be executed.

Why? I don't know. Probably some security measure baked into Android.

Very fortunately, Git provides a way to relocate our .git folder (and thus the hooks) while keeping the files in our intended location.

I made a directory in my Termux home simply called gitdirs for this purpose.

~ $ mkdir gitdirs

Cloning a repository

Finally, with all of that out of the way, we can actually start cloning repositories!

In order to use the custom git dir location, you'll need to use the --separate-git-dir option when cloning.

For example:

~ $ git clone --separate-git-dir=$HOME/gitdirs/ludum-dare-54 git@github.com:apples/ludum-dare-54.git

We are no longer waiting for Godot

Install the Godot editor from the play store or other means.

When importing a project, simply select your project.godot file as expected.

Use Termux to run further git commands such as status/commit/etc.

Final notes

  • If you're using Gboard, try switching it to floating window mode for a slightly better experience.
    • Also might be worth giving another keyboard app a shot, Hacker's Keyboard seems popular.
  • Unfortunately, it doesn't seem possible to export your game as an APK, you'll probably still need a desktop to do this.
  • Maximize your code editor for a better experience (the button is in the upper-right of the code editor).
  • Try adjusting your Display Scaling in the Editor Settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment