Track 05 · Lesson 2 of 7Working as a team with Git
Track 05 · Working as a team with Git
Starting work
Lesson 2 of 7· 6 min
Get the code once, then start every piece of work on a fresh branch made from the latest shared code. Most painful merge conflicts begin right here, with a branch started from an old copy.
Fresh or stale?
Let teammates merge, then start a branch
develop on GitHub
The real thing. Teammates merge here.
- 2c1d0e9
- 8a7b6c5
origin/develop
Your laptop’s copy of GitHub’s. Updated by git fetch.
- 2c1d0e9
- 8a7b6c5
develop (local)
Your own branch. Updated by git pull.
- 2c1d0e9
- 8a7b6c5
Now start your branch from…
Merge a teammate’s PR or two, then try each way of starting a branch.
Three copies of the same branch#
There are three versions of the target branch in play: the real one on GitHub, your laptop's copy of GitHub's (origin/develop), and your own local branch (develop). Teammates merge into the first one all day. The other two only change when you ask: git fetch updates your copy of GitHub's, and git pull updates both.
That's why a branch made from your local develop can start days behind. Either git pull first, branch from origin/develop right after a git fetch, or let gh issue develop create the branch on GitHub itself.
Get the team's repo on my laptop#
When: You need the code for a project for the first time.
Not sure of the exact repo name? List everything in the organization.
Commands to copy
$ gh repo list your-orgFind the repo name
$ gh repo clone your-org/appDownload it
$ cd appGo into the folder
I was assigned an issue. Where do I start?#
When: Your lead assigned you a ticket on GitHub.
"@me" means you. Keep the quotes, they matter in PowerShell.
Commands to copy
$ gh issue list --assignee "@me"My issues
$ gh issue view 42Read one
$ gh issue develop 42 --checkout --base developBranch for it, linked to the issue
$ git switch -c feat/signup-fix origin/developOr: make a branch with your own name (plain Git)
Check yourself