-
Notifications
You must be signed in to change notification settings - Fork 26
Labels
approvedexercise discussionDiscussion about the design of an exerciseDiscussion about the design of an exercise
Description
Existing exercise check
- I have verified that this exercise is not yet already in discussion, in progress, or exists
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:
- Start a new branch named
visitor-line, starting from the second commit (i.e., commitAdd second line). - Add the line
I heard someone knocking at the door.to thestory.txt. - Commit the change. You may use any suitable commit message.
- Start a new branch named
sleep-line, starting from the same starting point as before. - Add the line
I fell asleep on the couch.to thestory.txt. - 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"
Exercise grading
Verify that,
- the
visitor-linebranch has the expected commit sequence, containing the expected change. - the same for the
sleep-linebranch
Requires remote repository?
No response
Additional remarks
No response
Metadata
Metadata
Assignees
Labels
approvedexercise discussionDiscussion about the design of an exerciseDiscussion about the design of an exercise