0
0
Gitdevops~5 mins

Editing commit messages with rebase in Git - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What command starts an interactive rebase to edit commit messages?
Use git rebase -i HEAD~n where n is the number of commits you want to edit.
Click to reveal answer
beginner
In an interactive rebase, how do you mark a commit to edit its message?
Change the word pick to reword next to the commit you want to edit.
Click to reveal answer
beginner
What happens after you save and close the rebase todo list with reword commits?
Git opens an editor for each reword commit so you can change its message.
Click to reveal answer
beginner
How do you finish the rebase after editing commit messages?
Save and close the commit message editor for each commit, then Git completes the rebase automatically.
Click to reveal answer
intermediate
Why should you be careful when rebasing commits that are already shared with others?
Because rebasing rewrites history, it can cause problems for others who have the old commits.
Click to reveal answer
Which command lets you edit the last 3 commit messages?
Agit commit --amend
Bgit rebase -i HEAD~3
Cgit log -3
Dgit reset --soft HEAD~3
In the rebase todo list, which word should you replace pick with to change a commit message?
Areword
Bfixup
Cedit
Dsquash
What does Git do after you save the rebase todo list with reword commits?
AOpens an editor for each commit message to be changed
BDeletes the commits
CAutomatically merges commits
DPushes changes to remote
What should you do after editing all commit messages during a rebase?
ARun git push --force
BRun git commit --amend
CRun git merge
DSave and close the editor to let Git finish the rebase
Why is it risky to rebase commits that others have already pulled?
AIt deletes the remote repository
BIt slows down Git performance
CIt rewrites history, causing conflicts for others
DIt automatically merges unrelated branches
Explain the steps to edit commit messages using interactive rebase.
Think about how you tell Git which commits to change and how you update messages.
You got /5 concepts.
    Why should you avoid rebasing commits that have been pushed to a shared repository?
    Consider what happens when history changes after sharing.
    You got /4 concepts.