Rebasing and Resolving Conflicts Flashcards

1
Q

Q: What is rebasing in Git?

A

A: Rebasing is a process of moving or combining commits to create a linear commit history.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Q: How do you rebase the current branch onto another branch?

A

A: Use git rebase <branch-name>.</branch-name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Q: What is the difference between git merge and git rebase?

A

A: Merging preserves the commit history as-is, while rebasing rewrites it into a linear sequence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Q: How do you start an interactive rebase?

A

A: Use git rebase -i <base-commit>.</base-commit>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q: What does the term “base commit” mean in rebasing?

A

A: It refers to the commit where the rebase begins, typically the parent branch.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Q: What are the actions you can perform in an interactive rebase?

A

A: Pick, reword, edit, squash, fixup, and drop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q: What does “pick” mean during an interactive rebase?

A

A: It keeps the commit as-is.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q: What does “squash” mean during an interactive rebase?

A

A: It combines the commit with the previous one while keeping the commit messages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Q: What does “reword” mean during an interactive rebase?

A

A: It edits the commit message while keeping the changes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Q: What does “fixup” mean during an interactive rebase?

A

A: It combines the commit with the previous one without keeping the commit message.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Q: What does “drop” mean during an interactive rebase?

A

A: It deletes the commit entirely from the history.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Q: How do you resolve a conflict during a rebase?

A

A: Manually edit the conflicting files, stage the changes using git add, and continue the rebase with git rebase –continue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Q: How do you abort a rebase?

A

A: Use git rebase –abort.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Q: What command shows the base commit shared between two branches?

A

A: Use git merge-base <branch1> <branch2>.</branch2></branch1>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Q: How do you reapply stashed changes after a rebase?

A

A: Use git stash apply or git stash pop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Q: How do you skip a commit during a rebase if conflicts cannot be resolved?

A

A: Use git rebase –skip.

17
Q

Q: What does the –onto option do in rebasing?

A

A: It allows you to rebase a branch onto a different base branch or commit.

18
Q

Q: How do you perform a rebase to squash all commits into one?

A

A: Use git rebase -i <base-commit> and mark all commits except the first one as squash or fixup.</base-commit>

19
Q

Q: How do you ensure that a branch always rebase instead of merge when pulling?

A

A: Use git config pull.rebase true or git pull –rebase.

20
Q

Q: What are conflict markers in a file?

A

A: Conflict markers are «««<, =======, and&raquo_space;»»>, which indicate sections of code in conflict.

21
Q

Q: What does git diff show during a rebase conflict?

A

A: It shows the differences between the conflicting files and the base commit.

22
Q

Q: How do you view a list of ongoing rebase steps?

A

A: Use git status during a rebase to see the current state.

23
Q

Q: What happens to the commit hashes when you rebase?

A

A: Rebasing rewrites the commit history, so all rebased commits get new hashes.

24
Q

Q: How do you avoid rebasing branches that are shared with others?

A

A: Never rebase branches that have already been pushed to a remote and are used by others.

25
Q

Q: How do you rebase a branch to update it with the latest changes from the main branch?

A

A: Switch to the branch and use git rebase main.