Remotes — Fetch, Pull and Push
A remote is another copy of the repository — on a hosting service, a server, a folder on the same disk — that your branches can track. Working with one is three verbs: fetch (look at what the remote has, change nothing of yours), pull (fetch, then bring your branch up to date), and push (send your commits to the remote). This chapter covers all three from the Status panel's two small arrows. The outcome: you can read how far your branch has drifted in either direction, pull a colleague's commit down, and push yours up — and you know precisely which parts of that the lab verified against a folder, and which parts a real network adds.
The lab's remote, honestly labelled
The lab's remote was a bare repository
— a repository with no working tree, the
shape servers keep — created with
git init --bare in a folder beside the
fixture, and wired in as origin. A
second clone stood in for a colleague.
Every claim in this chapter was checked
against that arrangement with git itself,
and everything about it is local: no
network, no accounts, no keys. The verbs
and the arrows behave identically against
a network remote; what a network adds is
authentication and failure modes, listed
at the chapter's end and filed as
documented-only in criteria.md.
The arrows: ↓ and ↑
The Status panel keeps the score. When
the lab's "colleague" pushed a commit to
the remote that main did not have, the
panel read:
↓1 fixture → main
One commit exists upstream that you do
not have: you are behind. After the
lab made a commit of its own and had not
pushed, the panel read ↑1 — one commit
ahead. Level, it shows no arrow at
all. (Behind and ahead at once shows
both, and means the histories have
diverged — the pull below will have a
merge or a rebase in it, and chapter 11
may be in your near future.)
These arrows update when lazygit
fetches — fetch is the polite verb,
changing nothing but your knowledge of
the remote. It fetches when it opens
(the lab proved this against a local
record it had deliberately left stale:
the ↓1 was on screen before a single
key was pressed), again at an interval
the printed defaults put at sixty
seconds, and at once when you press
f — so the printed default
keybindings name it. The discipline the arrows
teach is the whole chapter in miniature:
look before you push, and never be
surprised by a number you could have
read first.
Pulling: p
With the panel showing ↓1, the lab
pressed p. No menu, no editor: the
hint of activity in the command log, and
the repository changed state —
- the colleague's commit, "README: a note from the other desk", appeared at the top of the Commits panel;
- the ↓1 vanished from the Status panel;
- and afterwards, outside the program,
git status -sbreported the branch level withorigin/main, andgit logshowed the pulled commit in place.
The pull was a fast-forward — the
remote's history was simply the local
history plus one, so the branch pointer
walked forward. When histories have
diverged, pull must reconcile them, by
merge or by rebase according to your
git configuration; lazygit drives the
same git pull you would have typed,
and shows you the same results, including
a conflict if one arrives (chapter 11).
Pushing: P
Capital P is push. The lab made a
commit locally — the panel duly showed
↑1 — pressed P, and watched the arrow
clear. The verification waited outside:
the bare repository's own log,
git -C ../remote.git log --oneline -1 main
showed the pushed commit at its tip,
identical to the local one. Push sends
commits; it does not send uncommitted
changes, stashes, or branches the remote
has never been told about. A new
branch's first push needs its upstream
set — the Branches panel's u (chapter
6's hint bar) handles upstreams, and
lazygit will prompt for one when a push
has nowhere defined to go. That prompt,
and the from-scratch upstream flow, are
documented behaviour the lab did not
exercise: its main was born tracking.
What a real remote adds
Against GitHub, a company server, or any
SSH or HTTPS remote, the arrows, f,
p and P are the same. Three things
change, none of them lazygit's doing:
- Authentication. SSH keys,
passphrases and HTTPS credential
helpers belong to git and your system.
When git needs a passphrase, lazygit
surfaces git's prompt inside its own
screen; it neither holds your keys nor
invents its own store. Settle your
credentials with plain git first — if
git pushworks in the terminal,Pworks here. - Refusals. A push the remote rejects — most often because someone else pushed first — arrives as git's own error text in a popup, word for word. The remedy is the command line's too: pull (and reconcile), then push again. The arrows, read on arrival, prevent most of these.
- Latency and failure. A folder never times out. A network does, and lazygit shows the spinner and, eventually, git's complaint. Nothing about your repository is at risk in a failed fetch or push: both are conversations, and a conversation that fails leaves the local history exactly as it was.
Check for the whole chapter, and the one
the lab ended on: after any pull or
push, git log --oneline -1 in the
repository and the same command against
the remote should name the same commit.
When they do, the arrows were telling
the truth, and so is the screen.