Your repository on GitHub · lesson 9 of 9
Commands and ideas in this lesson
Agit fetch, git statusfrom lesson 4.6
Bgit pullfrom lesson 4.6
CRejected pushfrom lesson 4.7
Dgit push -u origin <branch>from lesson 4.6

Kusina on GitHub

Last updated

Kusina is on GitHub now, and changes come from two places: Ana's laptop, and GitHub itself, where she and Joaquin edit in the browser. In this project you'll bring a browser edit down to the laptop, settle a clash between the laptop and GitHub, and push a branch that's ready for Stage 5's first pull request.

By the end of this lesson you can

  • Bring a commit made on GitHub down to your computer
  • Recover from a push rejected because of a browser edit, and settle the clash
  • Push a new branch to GitHub

The brief

You're Ana, in kusina on your laptop. It's connected to Kusina on GitHub as origin. This morning, on your phone, you edited the README on GitHub to add Lola Remy's advice.

  1. Find out what GitHub has that your laptop doesn't, without changing anything: fetch, then status.
  2. Pull it down, and find the README commit in your history.
  3. Lola says the leche flan needs 45 minutes. Change the steaming line in leche-flan.md, commit, and push. (Joaquin is editing on GitHub at the same time.)
  4. If the push is rejected, pull, settle the clash on 45 minutes, commit and push.
  5. Start a branch ube-halaya, add ube-halaya.md with a title and a line or two, commit, and push the branch to GitHub with an upstream.

Build it

Git sandbox
  1. Fetch, then see with git status that you’re behind
  2. Pull, and have the README commit in your history
  3. Commit the leche flan at 45 minutes
  4. GitHub’s leche flan says 45 minutes, with Joaquin’s commit in your history and no conflict markers left
  5. The ube-halaya branch pushed to GitHub

Working folder

no changes

Staging area

nothing staged

Repository

10 commits on main

Remote

origin: example.com/ana/kusina.git · in step, as of your last fetch

You are in ~/kusina, connected to Kusina on GitHub as origin. This morning you edited README.md on GitHub, in your phone’s browser.

Commit graph

  1. 67e435d HEAD →mainorigin/main Cover the leche flan with foil
  2. ba04ca2 Add lumpiang shanghai recipe
  3. 98a5edc Add a script that builds the index page
  4. d078487 Make the sinigang steps clearer
  5. 145dc1e Add pancit bihon recipe
  6. 52d1f4d Say how much salt goes in the adobo
  7. 1c17fad Add a README
  8. 9c53888 Add leche flan recipe
  9. 1f359a2 Add sinigang recipe
  10. 601c654 Add adobo recipe

On GitHub, pushing a new branch makes a yellow banner appear on the repository page: "ube-halaya had recent pushes", with a Compare & pull request button. Lesson 5.2 presses it.

Spot the trap: editing in two places

Spot the trapAna

Ana often fixes a typo on GitHub from her phone, then carries on working on her laptop without pulling. Every few days her push is rejected and she has to merge.

What happens if…

Check your history

Run git log --oneline --graph -6. You should see your 45-minute commit and Joaquin's 50-minute commit side by side, joined by a merge commit, with the README commit below them.

Ana edited the README on GitHub. Why did her laptop’s git status only say “behind” after git fetch?
Joaquin’s edit on GitHub and Ana’s commit changed the same line. Where did the conflict have to be settled?

Sources

Every command on this page behaves as these pages describe, and the sandbox prints what Git 2.55 prints. Hosting features (pull requests, protected branches) come from the host’s own documentation.

All sources for Simple Git