Module 2 · Git: the 20 everyday commands · Lesson 13 of 16
Rebase, cherry-pick and stash
Replay a branch on a new base, copy one commit across, and park unfinished work.
In this lesson · about 24 minutes
- Use git rebase to replay a branch on top of the latest main
- Copy a single commit from another branch with git cherry-pick
- Put unfinished changes aside with git stash, and bring them back with git stash pop
Key terms
Say the meaning to yourself, then tap a card to check.
Whiteboard · watch and try
Merge versus rebase
Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.
Practice terminal · missions
Tidy history, rescue a fix, and juggle unfinished work
Missions 0 of 10
- 1Switch to the contact-page branch.
- 2Replay contact-page on top of the latest main.
- 3Look at the history.
- 4Switch to main and merge contact-page.
- 5Look at the history of the experiments branch.
- 6Copy just the 'Fix heading colour' commit into main.
- 7Start some unfinished work: echo "Free wifi" >> index.html
- 8Put the unfinished change in the stash drawer.
- 9List what is in the stash.
- 10Bring the unfinished work back.
Type a command and press Enter. Try help to list commands. Tab finishes names, ↑ repeats.
Repository ~/website · on main
1 · Working folder
The files you edit
- README.mdsaved
- hours.txtsaved
- index.htmlsaved
- style.csssaved
2 · Staging area
Packed for the next commit
- (nothing staged: use git add)
3 · Commit history (this computer)
Each dot is a saved snapshot. Labels are branches, tags and what you last heard from origin.
☁ Remote: origin
https://github.example/sam/website.git
- maince42faeAdd opening hourssame as yours
- contact-pageb85c626Link contact page from homesame as yours
Check your understanding0 of 4 correct
Quiz score: 0 of 4
Written by Noviq Academy in its own words. The practice terminal is a simulation that runs in your browser: it imitates Linux (Ubuntu-style output) and Git closely, but it is not a real computer, and real output can differ slightly. The servers, people, web addresses and GitHub addresses in the labs are made up. Linux is a trademark of Linus Torvalds; Git and GitHub belong to their owners. Read-aloud uses your device's built-in voices.