Git Management on Android

How to install a git management system by terminal on Android

My goal here is to install a Git management system, by terminal, on an Android phone using the exact same workflow as in Linux. And then be able to sync files and folders securely from Github & Gitlab.

We’ll use Termux terminal, but don’t get it from the PlayStore! The only working and up-to-date version is on F-Droid, the open-source deGoogled app store.

Install

  • Download and install the F-Droid APK package (you need to authorize Unknown sources)
  • Update F-Droid respositories
  • Search for Termux on the store, then install it
  • Run Termux
  • Install the following base packages from command line:
pkg install git openssh

Enable access to share storage within Termux by running:

termux-setup-storage

Configure Git

Create Git global config on your phone:

git config — global user.name 'John Doe'
git config — global user.email 'johndoe@example.com'

Setup SSH Keys

Before cloning your repo, setup your SSH key:

touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
ssh-keygen
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_key
chmod 600 ~/.ssh/authorized_keys
sshd

Copy your SSH key into Gitlab.com account preferences > SSH keys:

cat ~/.ssh/id_rsa.pub 

then copy/paste into Gitlab.com

Clone repo(s)

mkdir ~/storage/shared/Repos
cd ~/storage/shared/Repos
git clone git@gitlab.com:user/repo.git

Aliases

Like in any Linux distro, add aliases to .bashrc.

The file default storage is: /data/data/com.termux/files/home/ but you may want to create a new .bashrc file in your personal folder.

Iinstall vim package to edit text/config files, then create .bashrc:

pkg install vim
vim ~/.bashrc

Add your aliases, here are some I often use:

alias la="ls -a"
alias repo="cd ~/storage/shared/Repos"
alias push="git pull && git add . && git commit -m 'mobile push' && git push"

Refresh the source:

source ~/.bashrc

Now you have a fully functional terminal on your phone!

Have fun!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rphl-Mstl

Rphl-Mstl

106 Followers

OS explorer, UI & UX passionate, Voxels crafter, code lover, Video Games player, Podcasts listener, Music amateur // Digital Publishing professional