How to install Git on Android

There may be times when you need to work with Git, and the only device you have is your Android smartphone. When that's the case, what do you do? Thanks to a handy tool called Termux, it is possible to install the command line Git tool on a mobile device.

I'm going to walk you through the process of getting this up and running. I'll demonstrate on Android 9, running on an Essential PH-1.

Once installed, you'll have the full complement of tools found in the command line version of Git.

SEE: VPN usage policy (TechRepublic Premium)

What you need

The only things you need are a device running version 5.0 or newer of the Android platform and a GitHub account. That's it.

Let's make this happen.

Installing Termux

The first thing to do is install Termux. This is done from the Google Play Store, by following these steps:

Once installed, you'll find a launcher for Termux on your home screen and/or your App Drawer. Locate that launcher and open the app. When the app opens, you should see a somewhat familiar terminal window (Figure A)

Installing Git and SSH

Before you can run the installation command, you need to update and upgrade. To do that, issue the command (Figure B):

When the upgrade completes, you are ready to install both Git and SSH. To do that, issue the command:

This command (Figure C) will install both necessary apps.

Set up Git storage

It's now time to set up Termux Storage. This is done with the command (from the Termux terminal):

Upon running that command, you will be prompted to allow the app access to storage. Do so, and you're ready for Git.

Connecting to GitHub

This is where it gets slightly tricky. From the Termux terminal, you must first create an ssh keypair. To do this, issue the command:

Where EMAIL is your email address associated with your GitHub account.

Once you generate the key, I suggest you use the scp command to copy it to a desktop computer. So change into the .ssh directory (on Termux) with the command:

From within that directory, issue the command:

Where USER is a remote username and IP is the remote address of a desktop on the same network as your Android device (that accepts SSH connections).

Once you have that file stored on a remote desktop, you need to log into GitHub (from the desktop now housing the .pub file) and go to Settings | SSH Keys. Copy that id_rsa.pub key into Git and save it.

Logging into Git

Now that you copied your SSH public key to GitHub, you can log into your GitHub account with the command:

Once you authenticated, you are ready to start working with Git from your Android device. Create repositories, push, pull, and more. You might want to also do yourself a favor and install the nano editor, via Termux (with the command apt install nano), so you can actually edit code.

And there you go. A handy way to work with Git on your Android device. Now ... git to work.

Also see