Skip to main content

How to save git project file on Android

ยท 2 min read

Connect without adbโ€‹

# 1. install Termux (use F-Droid)

# --- on termux
# 2. update Termux
pkg update && pkg upgrade
pkg install termux-services
# 3. install git and openssh
pkg install git openssh
# 4. setup ssh server
passwd # setup termux password
sshd # start ssh server
# 5. get username
whoami

# --- on PC
arp -n # another way to get smartphone IP
# connect SSH (termux default port is 8022)
ssh -p 8022 u0_a334@10.92.92.3

# change git remote origin
git remote set-url origin ssh://u0_a334@10.92.92.3:8022/data/data/com.termux/files/home/git/myqrdocs.git
tip

The forwarding via adb:

adb forward tcp:8022 tcp:8022

Is used only if you want to connect without use any networking. You can always use Tethering USB without internet to stay isolated.

How to connect to your Android using SSH with cable with ADBโ€‹

danger

These ADB commands are just for documentation.

DO NOT LEFT Debug mode switched on pls :P

# --- now on pc
# 0. install adb
# 1. close adb
adb kill-server
# 2. connect the android, use a cable with Vcc, Gnd pairs, Data+, Data-
# 3. authorize device
adb devices
# 2. do port forwarding
adb forward tcp:8022 tcp:8022
# 3. connect to android using the port
ssh -p 8022 username@localhost
# example:
# ssh -p 8022 u0_a334@localhost

Setup git bare repoโ€‹

# 1. ssh into termux
ssh -p 8022 u0_a334@localhost
# home is in:
# /data/data/com.termux/files/home
# 2. create dir
mkdir -p ~/git/mio-progetto.git
cd ~/git/mio-progetto.git
git init --bare
# --- now on pc
git clone ssh://u0_a334@localhost:8022/data/data/com.termux/files/home/git/myqrdocs.git
# on config --list you should see the full connection URL
git config --list
# you can now commit and push
git commit -m ""
git push origin