BYTESLIP ← Back
Knowledge Base // Tutorial 59 · Termux

Git Basics in Termux: Clone, Status, Commit and Push

Difficulty: Medium ~15–25 min Termux · F-Droid

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).

Git in Termuxpkg install gitclone · status · commit · pushkeep repos in ~/projectsMEDIUM · GIT BASICS
Checklist // Before You Start

What You Need

Walkthrough // Steps

Install git → clone → commit → push carefully

  1. 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).

  2. 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 ~/projects over ~/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.

  3. 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 status before and after keeps you honest about what’s staged. Keep commits small on mobile—reviewing huge diffs on a phone screen is painful.

  4. 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.

  5. 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 .gitignore before the first commit.
Pro Tip
Sources // Verified
← All Tutorials Termux tutorials Install Termux