Skip to content

[Exercise Discussion] T6L1/branch-previous #65

@damithc

Description

@damithc

Existing exercise check

Lesson

https://nus-cs2103-ay2526s1.github.io/website/book/gitAndGithub/branch/index.html

Exercise learning outcomes

Able to create a branch to start from a previous commit (not the HEAD commit)

Exercise setup

Inputs to the new.sh:

Exercise name: branch-previous
Tags (space separated): git-branch
Requires Git? (defaults to y)  [y/N]: y
Requires Github? (defaults to y)  [y/N]: N
Exercise repo type (local, remote, or ignore) (defaults to 'local'): local
Exercise repo name (defaults to ...): horror-story
Git-Mastery Github repository title (defaults to ''): 
Initialize exercise repo as Git repository? (defaults to y)  [y/N]: Y

Equivalent steps to populate the repo

echo -e "It was a dark and stormy night." >> story.txt
git add .
git commit -m "Describe night"
"I was alone in my room." >> story.txt
git commit -am "Describe location"
echo "I heard a strange noise." >> story.txt
git commit -am "Mention noise"

Instructions for students

Scenario: You are writing the outline for a story, in story.txt. You have written the first few steps of the storyline. You are not very happy with the way the story is progressing, and wish to explore a few alternative storylines starting from a previous step.

Task:

  1. Start a new branch named visitor-line, starting from the second commit (i.e., commit Add second line).
  2. Add the line I heard someone knocking at the door. to the story.txt.
  3. Commit the change. You may use any suitable commit message.
  4. Start a new branch named sleep-line, starting from the same starting point as before.
  5. Add the line I fell asleep on the couch. to the story.txt.
  6. Commit the change. You may use any suitable commit message.

Expected revision graph:

gitGraph BT:
  commit id: "Describe night"
  commit id: "Describe location"
  branch visitor-line
  checkout main
  branch sleep-line
  checkout main
  commit id: "Mention noise"
  checkout visitor-line
  commit id: "Mention knocking"
  checkout sleep-line
  commit id: "Mention sleeping"
Loading

Exercise grading

Verify that,

  • the visitor-line branch has the expected commit sequence, containing the expected change.
  • the same for the sleep-line branch

Requires remote repository?

No response

Additional remarks

No response

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions