In this lab, you're going to use git rebase --interactive to take an outdated
feature branch and move it to the latest commit on main.
The product team has told us that a work-in-progress feature needs to be reprioritized. This feature was partially completed, and then put on hold. The branch is still present, so let's bring it back up to date and deliver that feature.
-
Checkout the feature branch
git checkout feature/animate-score
-
Verify the feature branch is behind
maingit log --oneline --graph --all
In the graph output, you should see that the
feature/animate-scorebranch was created from an earlier commit onmain.... * a4f1x35 Update scoreboard size * f723e2f Remove comment * d2b828f Revert change | * 0f3cb0b (HEAD -> feature/animate-score) Animate score update |/ * 35710de (origin/main) Add watch script * 6181c9c Update ESLint config
-
Interactively rebase the feature branch onto
maingit rebase --interactive main
In the editor that opens, you should see a list of commits. The first commit is the one that the branch was created from, and the last commit is the most recent commit on
main.pick 0f3cb0b Animate score update pick a4f1x35 Update scoreboard size pick f723e2f Remove comment pick d2b828f Revert changeIn this exercise, we want to combine all the commits on the
feature/animate-scorebranch into a single commit. This will make it easier to follow the changes in the commit history. -
Update the commit list to squash all the commits into a single commit and modify the commit message.
reword 0f3cb0b Animate score update squash a4f1x35 Update scoreboard size squash f723e2f Remove comment squash d2b828f Revert changeSave and close the editor.
Hint: If you are using VI or VIM, you can save and close the editor by pressing
ESC, typing:wq, and pressingEnter. -
You will be prompted to modify the message for the reworded commit. The message will be pre-filled with the original commit message. If you want to keep the original message, simply save and close the file. Otherwise, modify the message as needed and save and close the file.
-
Verify that the feature branch is now up to date with
maingit log --oneline --graph --all
In the graph output, you should see that the
feature/animate-scorebranch is now based on the most recent commit onmain.* 0f3cb0b (HEAD -> feature/animate-score) Animate score update * 35710de (origin/main) Add watch script * 6181c9c Update ESLint configIn the example above, the topmost commit message should be set to whatever value you provided in the previous steps.
Now that you've rebased the feature branch, you should switch back to the main
branch so you can merge your changes!
-
Checkout the
mainbranchgit checkout main
-
Merge the
feature/animate-scorebranch into themainbranchgit merge feature/animate-score
-
Push your changes to GitHub
git push
-
Navigate to your repository on GitHub.com
-
Click the Actions tab
-
Click the running Deploy to GitHub Pages workflow
-
Wait for the workflow run to complete
-
Click the Code tab
-
Click the link to your game
-
Verify the game score updates are animated
If you're having trouble with any of the steps, you can ask for help in the meeting chat.
The code changes for this lab can be found in the solutions directory.
- Copy the contents of
solutions/4-interactive-rebase/html_actuator.tsand replace the contents ofsrc/html_actuator.ts