Rebasing and Resolving Conflicts Flashcards
Q: What is rebasing in Git?
A: Rebasing is a process of moving or combining commits to create a linear commit history.
Q: How do you rebase the current branch onto another branch?
A: Use git rebase <branch-name>.</branch-name>
Q: What is the difference between git merge and git rebase?
A: Merging preserves the commit history as-is, while rebasing rewrites it into a linear sequence.
Q: How do you start an interactive rebase?
A: Use git rebase -i <base-commit>.</base-commit>
Q: What does the term “base commit” mean in rebasing?
A: It refers to the commit where the rebase begins, typically the parent branch.
Q: What are the actions you can perform in an interactive rebase?
A: Pick, reword, edit, squash, fixup, and drop.
Q: What does “pick” mean during an interactive rebase?
A: It keeps the commit as-is.
Q: What does “squash” mean during an interactive rebase?
A: It combines the commit with the previous one while keeping the commit messages.
Q: What does “reword” mean during an interactive rebase?
A: It edits the commit message while keeping the changes.
Q: What does “fixup” mean during an interactive rebase?
A: It combines the commit with the previous one without keeping the commit message.
Q: What does “drop” mean during an interactive rebase?
A: It deletes the commit entirely from the history.
Q: How do you resolve a conflict during a rebase?
A: Manually edit the conflicting files, stage the changes using git add, and continue the rebase with git rebase –continue.
Q: How do you abort a rebase?
A: Use git rebase –abort.
Q: What command shows the base commit shared between two branches?
A: Use git merge-base <branch1> <branch2>.</branch2></branch1>
Q: How do you reapply stashed changes after a rebase?
A: Use git stash apply or git stash pop.