Skip to content

How to Use Git and GitHub on Your iPhone

You can push a fix from your phone. Properly, from a terminal, with real commit history. That still surprises people, so it's worth showing what's actually in there.

The git in DevBox is built on libgit2 and reports itself as 2.43.0. That means a curated set of commands rather than every flag git has ever grown, and the set covers the work you'd realistically do away from a desk:

init, clone, add, commit, status, log, diff, show, branch, checkout, switch, merge, push, pull, fetch, remote, reset, restore, stash, tag, rm, mv, clean, reflog, rev-parse, rev-list, ls-files, config, lfs, credential.

What's not in there is the history surgery: rebase, cherry-pick, bisect, and shallow clone. Those are desk jobs anyway, and the ones you'd least want to attempt with a thumb on a moving train. Everything in the list above is the loop you actually use when you're out and something needs fixing.

Before your first commit

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Skip it and git refuses to commit. Use the email tied to your GitHub account or your commits show up unattributed.

Cloning and the token dance

git clone https://github.com/user/project.git

Private repo, and it prompts you in the terminal:

Username for 'https://github.com':
Password for 'https://github.com':

GitHub hasn't accepted account passwords for years, so the password prompt actually wants a personal access token. Settings, Developer settings, Personal access tokens, repo scope.

Paste it in. When the clone succeeds DevBox writes the token into the iOS keychain and stops asking for that host from then on. If it fails, nothing gets saved, so a mistyped token never sticks around to confuse you later.

One practical note. A big repository pulls the full history, so give it Wi-Fi and a minute rather than starting it as you walk into a tunnel.

The loop

git status
git add src/api.php
git commit -m "Return 404 instead of 500 on missing user"
git push

Branches are normal:

git switch -c fix/missing-user
git push -u origin fix/missing-user

Open the pull request from GitHub's own app afterwards, or when you're back at a desk. The commit and the push are the parts that had you reaching for a laptop, and those are the parts you now don't need one for.

Messages

Always -m. Getting dumped into a terminal editor you then have to escape from, on a touchscreen, is a bad five minutes.

Scope is the real point though. A phone commit should be one small thing. If you're drafting three paragraphs of justification in your head, that change wanted a keyboard, and probably wanted more thought than you're giving it standing up.

Reading other people's code

The Community tab searches GitHub. Query, language filter, download straight into your projects.

I use it for reading far more than building. Find a library, pull it down, open the source in an editor with proper highlighting instead of fighting GitHub's web view and its horizontal scrollbar.

Conflicts

Small ones, fine. Markers show up in the editor and you delete the half you don't want:

<<<<<<< HEAD
$limit = 20;
=======
$limit = 50;
>>>>>>> origin/main

Pick a side, delete the three marker lines, save, add, commit.

Anything bigger:

git merge --abort

Knowing when to stop is most of the skill. A conflict spanning six files is not something to untangle standing on a train with one hand on a rail.

Two commands to be careful with

git push --force and git reset --hard. Both work. Both will do precisely what you told them.

The rule you use at a desk applies here, then applies harder, because the screen is small and your thumb is not precise and you are probably half paying attention to something else.

What it's for

Not a day's work. Something narrower than that.

A typo you spot in production from a cafe. A config value that has to change before the deploy goes out tonight. Actually reading a diff, in an editor, instead of scrolling GitHub's mobile site. Pulling down a branch to see what someone wrote before you approve it.

Four minutes on a phone instead of an hour of finding a laptop.