Track 05 · Lesson 7 of 7Working as a team with Git

Track 05 · Working as a team with Git

Everyday extras

Lesson 7 of 7· 6 min

The small commands that make every day smoother: report a bug without losing focus, see what's waiting for you, jump to the browser, and run a deploy by hand. Then, your whole toolbox in one search box.

I found a bug but can't fix it right now#

When: You noticed something broken while working on something else.

$ gh issue create
1/6

Type this and press Enter.

Commands to copy

  • $ gh issue create

    Step by step

  • $ gh issue create --title "Signup button does nothing on Safari" --label bug --body "Steps: open /signup on Safari, click Sign up. Nothing happens."

    All in one line

What's waiting for me today?#

When: Start of the day, or coming back from a break.

$ gh pr status
1/3

PRs in this repo that involve you.

Commands to copy

  • $ gh status

    Everything that needs you, across repos

  • $ gh pr status

    PRs in this repo

  • $ gh issue list --assignee "@me"

    My issues

Just open it in the browser#

When: Some things are easier on the website: big diffs, screenshots, settings.

$ gh browse
1/5

Type this and press Enter.

Commands to copy

  • $ gh browse

    Repo home page

  • $ gh browse 123

    PR or issue by number

  • $ gh browse src/api/auth.ts

    A file

  • $ gh pr view --web

    My current branch's PR

Run a deploy workflow manually#

When: Your team has a GitHub Action you start by hand, like Deploy or Seed DB. On GitHub it shows a "Run workflow" button.

$ gh workflow run
1/8

Type this and press Enter.

Commands to copy

  • $ gh workflow run deploy.yml --ref develop -f environment=staging

    Run from the develop branch with an input

  • $ gh run watch

    Follow it live

  • $ gh run list --workflow=deploy.yml

    Past runs

Your whole toolbox

Every situation in this track, searchable

20 of 20 situations

Setting up

Open the lesson
  • First day: set up gh on my laptop

    $ winget install --id GitHub.cli
  • I have a work account and a personal account

    $ gh auth status

Starting work

Open the lesson
  • Get the team's repo on my laptop

    $ gh repo list your-org
  • I was assigned an issue. Where do I start?

    $ gh issue list --assignee "@me"

Before the PR

Open the lesson
  • What changed between my branch and develop?

    $ git fetch origin

Opening a PR

Open the lesson
  • Open a PR for my work

    $ gh pr create
  • My PR must go into develop, not main

    $ gh pr create --base develop
  • Oops, I opened the PR against the wrong branch

    $ gh pr edit 123 --base develop
  • My work isn't finished, but I want early feedback

    $ gh pr create --draft --base develop
  • My new work depends on a PR that isn't merged yet

    $ gh pr create --base feat/login-api
  • Add reviewers or labels to my PR

    $ gh pr edit 123 --add-reviewer alice,bob --add-label frontend

After the PR is open

Open the lesson
  • CI failed on my PR

    $ gh pr checks
  • My PR is out of date with develop

    $ gh pr update-branch 123
  • A reviewer asked for changes

    $ gh pr view 123 --comments
  • Merge my PR

    $ gh pr merge 123 --squash --delete-branch

Reviewing others

Open the lesson
  • A teammate asked me to review their PR

    $ gh pr list --search "review-requested:@me"

Everyday extras

Open the lesson
  • I found a bug but can't fix it right now

    $ gh issue create
  • What's waiting for me today?

    $ gh status
  • Just open it in the browser

    $ gh browse
  • Run a deploy workflow manually

    $ gh workflow run deploy.yml --ref develop -f environment=staging

Where this track leaves you#

You can now go from day one to a merged PR: set up gh, start fresh branches, check what you're sending, open PRs into the right place, handle CI and reviews, review others safely, and keep up with your day. Bookmark this lesson: the search box above is the whole playbook in one place, filled in with your setup.

Check yourself

You spot a bug while working on something else. What's the best move?