Git repository in your pocket

This guide will show you how you can potentially use your Android device
as a git repository!

Basically git compare the "repository" folder with the "clone" folder.
There is no need for a server like GitHub, GitLab, Bitbuket until you can mount that repository folder locally on your computer.
So you can create "repository" folder inside your Android device
and mount it with the help of sshfs in your desktop computer

Prerequisites: Android device with hardware keyboard and bluetooth mouse or at less Hacker’s Keyboard installed.

Note: You may want to replace the red things with the yours

Install Termux .
It works just like a normal Linux terminal emulator.
$ pkg update

Install OpenSSH
The sshd server is included in the openssh package and allows you to connect to your Android device over ssh.
$ pkg install openssh
and start the ssh server.
$ sshd
Your ssh service is now running on port 8022

Generate a Key Pair for SSH passwordless login because the Termux sshd server does not support password logins
$ ssh-keygen -b 4096 -t rsa

Copy your private key to your computer
$ scp ~/.ssh/id_rsa tondy@192.168.2.123:~/tablet.pem

Create your "repository" folder
$ mkdir ~/git
And there you go.

Now from your desktop computer you can mount it.
There is a lot of sshfs clients for Linux/Mac/Windows
Install sshfs
$ sudo apk add sshfs
I use Alpine linux as desktop os so my install command is "apk add".
Replace it with the "install command" for your system
Debian(Ubuntu,Mint) - sudo apt install sshfs
For Windows I prefer SftpNetDrive. It works out of the box

Then you can test it by connecting to your Android device
$ ssh -i ~/tablet.pem -p 8022 192.168.2.31
and mount your "repository" folder locally
$ mkdir ~/remote
$ sudo modprobe fuse
$ sshfs -p 8022 -o IdentityFile=/home/tondy/tablet.pem \
192.168.2.31:/data/data/com.termux/files/home ~/remote

$ cd ~/remote/git
$ git init --bare abvos.git
$ cd /tmp
$ git clone ~/remote/git/abvos.git
$ cd abvos
$ git remote add origin ~/remote/git/abvos.git
$ git remote -v
$ # etc ...


Comments

Popular Posts