Git Basics in Termux: Clone, Status, Commit and Push
Use Git on your phone for your own repositories: clone, check status, commit, and push. Package name: git. This is day-to-day version control—not hacking remotes you don’t own. Mobile push has extra gotchas (auth, battery, large clones).
What You Need
- F-Droid Termux + Wi‑Fi (clones can be large).
- A remote URL you control (HTTPS or SSH) and credentials/keys for that host.
- Optional: SSH client lesson if you prefer SSH remotes.
Install git → clone → commit → push carefully
Step 1: Install git and set identity
pkg update pkg install git git --version git config --global user.name "Your Name" git config --global user.email "you@example.com"
Use the same name/email you use on the host (or your noreply GitHub address).
Step 2: Clone into private storage
mkdir -p ~/projects && cd ~/projects git clone https://github.com/YOUR_USER/YOUR_REPO.git cd YOUR_REPO pwd ls
Prefer
~/projectsover~/storage/shared—shared storage can break Unix permissions and slow Git. For a first practice repo, create an empty private repo on the host, then clone that.Step 3: Status, edit, commit
git status echo "note from phone $(date -Iseconds)" >> NOTES.md git add NOTES.md git status git commit -m "Add phone note"
git statusbefore and after keeps you honest about what’s staged. Keep commits small on mobile—reviewing huge diffs on a phone screen is painful.Step 4: Push (when you’re ready)
git push -u origin HEAD
HTTPS will prompt for credentials (often a personal access token, not your account password). SSH needs a key already authorized on the host—see SSH client. Stay on Wi‑Fi for the first push.
Step 5: Mobile caveats checklist
- Auth: Prefer SSH keys or short-lived tokens stored carefully—not passwords pasted into chat apps.
- Size: Shallow clone when needed:
git clone --depth 1 URL(fine for reading; less ideal for heavy history work). - Battery / sleep: Large fetch/push can fail if Android suspends Termux—keep the screen on or use Wi‑Fi + charging for big ops.
- Conflicts: If push is rejected,
git pull --rebase(on your branch) then push again—don’t force-push shared defaults. - Secrets: Add
.env, key files, and dumps to.gitignorebefore the first commit.
- Package Management (
pkg install git): wiki.termux.com/wiki/Package_Management - Getting started (Git as a common use): wiki.termux.com/wiki/Getting_started