Tokenova Learn

Office-Ready Git · provided by Tokenova

Office playbook: Git on a real team

How to work with Git on a real team: the daily routine, the etiquette, and what to do when things get messy.

Open the interactive version

  1. Your daily Git routine
  2. Team conventions
  3. Code review etiquette
  4. The never-do list
  5. Work identity vs personal identity
  6. Asking for help (and getting it fast)
  7. Which tool for which job?

Your daily Git routine

Most Git trouble on a team comes from working on stale code, or from sitting on work for too long. This routine prevents both.

WhenDo thisWhy
Start of daygit switch main, then git pullGet everything your team merged since yesterday.
Start a taskgit switch -c feature/7-supplier-filterA fresh branch from an up-to-date main, one per task.
While workinggit status before every git add. Commit small, working steps.You see exactly what goes in, and each commit is easy to review and undo.
At least dailygit push (the first time: git push -u origin <branch>)Your branch is backed up on GitHub, and your team can see progress.
Before a pull request (PR)git fetch, bring main into your branch the way your team does it (rebase or merge), run the tests, read your own diffReviewers see a clean change that works on today's main.
After your PR mergesgit switch main, git pull --prune, git branch -d <branch>Stay current and keep your branch list short. After a squash-merge, -d refuses: use -D once the PR shows Merged.

Open this section in the interactive guide

Team conventions

Every team has its own rules. Look for a CONTRIBUTING.md file, and read git log --oneline on main to copy the style you see. The course's lab kit (the Github_Learning folder from Day 1) has ready-made examples in samples/.

ThingCommon conventionExample
Branch nametype/issue-short-description, lowercase with hyphensfeature/7-supplier-filter, fix/14-discount-cap, hotfix/1.2.1
Commit subjectImperative, about 50 characters, capital letter, no full stopCap discounts at 100 percent
Commit bodyWhy the change was needed, wrapped at about 72 charactersDiscounts above 100% produced negative totals…
PR titleWhat it does, like a commit subjectCap discounts at 100 percent
PR descriptionWhat / Why / How tested / What to look at, plus Closes #14See samples/pr-description.md
PR sizeSmall: aim for under ~300 changed linesSplit big work into a series of PRs

Open this section in the interactive guide

Code review etiquette

Review is how a team shares knowledge. Comment on the code, never the person, and label how important each comment is:

LabelMeansExample
blocking:Must change before mergingblocking: this reads the password from a file in the repo. Could we use an environment variable?
suggestion:Worth considering, the author decidessuggestion: sum() might read more clearly than the loop.
question:You want to understandquestion: why do we round before tax, not after?
nit:Tiny, optionalnit: typo in the docstring.
praise:Something done wellpraise: great test name.

Receiving review: say thanks, reply to every comment ("Done in a1b2c3d" or why not), and push fixes as new commits on the same branch. If a thread goes back and forth more than twice, have a quick call instead.

Open this section in the interactive guide

The never-do list

Each of these has cost real teams real days:

  • Never force-push to main or any branch others use. On your own branch after a rebase, use git push --force-with-lease, never plain --force.
  • Never commit secrets: passwords, .env files, API keys, tokens. If it happens, rotate the secret first, then clean up (see Rescue).
  • Never commit data files or big binaries. GitHub warns over 50 MB and rejects files over 100 MB. Data lives in the warehouse or storage, not in Git.
  • Never rebase a branch someone else has pulled. Rewriting shared history breaks their copy.
  • Never git add . without reading git status first.
  • Never work directly on main. Branch first, even for a one-line fix.
  • Never git reset --hard with uncommitted work you care about. Commit or stash it first.
  • Never resolve a conflict by blindly taking your side. You might delete a teammate's fix.
  • Never delete the folder and re-clone "to fix Git" before asking. You can lose work that only existed on your laptop.

Open this section in the interactive guide

Work identity vs personal identity

Every commit records user.name and user.email, and GitHub links commits to accounts by that email. Your global settings may use a personal address. At work, company repos should get your work email. Git can switch automatically based on the folder a repo lives in.

  1. Keep all work repos under one folder, for example C:\work\.
  2. Create the file .gitconfig-work in your home folder with VS Code: code $HOME\.gitconfig-work. Put these lines in it:

    [user]

    email = you@yourcompany.com

  3. Tell Git to use that file for every repo under C:\work\: git config --global includeIf.gitdir/i:C:/work/.path '~/.gitconfig-work'
  4. Check it: inside a work repo, git config user.email shows the work address. Anywhere else, it shows your personal one.

Open this section in the interactive guide

Asking for help (and getting it fast)

When Git surprises you, a good question gets a quick answer. Paste these five things into the chat:

  1. What you were trying to do, in one sentence.
  2. The exact command you ran.
  3. The complete message Git printed (copy it, don't retype it).
  4. The output of git status.
  5. The output of git lg -8 (or git log --oneline --graph -8), and whether you've pushed.

Open this section in the interactive guide

Which tool for which job?

JobEasiest inAlso fine
Stage exactly the right linesVS Code: select lines in the diff, then Command Palette › Git: Stage Selected RangesGitHub Desktop (click line numbers)
Commit, push, pull, switch branchesAny of themPick one and get fluent
Resolve a merge conflictVS Code merge editorGitHub.com for small conflicts in a PR (Resolve conflicts)
See history as a graphgit log --oneline --graph --all in the terminal (the course's git lg alias), or VS Code's Graph viewGitHub Desktop History (one branch at a time)
Rebase, reflog, reset, cherry-pick, bisectTerminalDesktop and VS Code cover some of these
Open, review and merge pull requestsGitHub.comGitHub Desktop can start one for you
Branch protection, Actions, releasesGitHub.comn/a

Open this section in the interactive guide