Track 05 · Lesson 3 of 7Working as a team with Git
Track 05 · Working as a team with Git
Before the PR
Lesson 3 of 7· 6 min
Before you ask anyone to review, look at exactly what you're about to send them. Two Git commands do it, and the difference between two dots and three dots decides whether the answer is right.
Two dots or three?
Pick a command, then untick the fetch
$ git log --oneline origin/develop..HEADa1c9e2f fix: handle empty email7b3d004 feat: add login form
Two dots with log: commits you have that develop doesn’t. Exactly your work.
Reading the dots#
With git log, two dots A..B means "commits in B that aren't in A". So origin/develop..HEAD is your work, and flipping it, HEAD..origin/develop, is what teammates merged since you started.
With git diff, use three dots. origin/develop...HEAD compares your branch with the point where it left develop, so it shows only your changes. Two dots with diff compares the two tips directly, so anything a teammate added looks like something you deleted.
And always git fetch origin first. Without it, origin/develop is an old snapshot, and every comparison answers the wrong question confidently.
What changed between my branch and the target?#
When: Before opening a PR, you want to see exactly what you are about to send, or whether develop moved ahead since you started.
Get the latest from GitHub first. Otherwise you compare against an old copy.
Commands to copy
$ git fetch originAlways first
$ git log --oneline origin/develop..HEADMy commits that develop doesn't have
$ git diff --stat origin/develop...HEADWhich files I changed
$ git diff origin/develop...HEADThe actual line-by-line changes
$ git log --oneline HEAD..origin/developWhat develop has that I don't
$ gh pr diff --name-onlyOnce the PR exists: just the changed file names
Check yourself