Branching & Merging Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How do you create a new branch?

A

git branch branch_name

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

How do you switch to an existing branch?

A

git checkout branch_name

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

How do you merge changes from one branch into another?

A

git merge source_branch

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

How do you delete a local branch?

A

git branch -d branch_name

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

How do you list all branches in the repository?

A

git branch –all

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

How do you create a new branch and switch to it in one command?

A

git checkout -b branch_name

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

How do you rename a branch?

A

git branch -m old_name new_name

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

How do you show the commit history of a specific branch?

A

git log branch_name

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

How do you merge a branch and create a merge commit even if the merge could be a fast-forward?

A

git merge –no-ff branch_name

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

How do you abort a merge in case of conflicts?

A

git merge –abort

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

How do you list branches that contain a specific commit?

A

git branch –contains commit_hash

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

How do you compare the differences between two branches?

A

git diff branch1 branch2

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

How do you show the commit history of a branch

A

excluding merges?

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

How do you rebase a branch onto another branch?

A

git rebase target_branch

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

How do you abort a rebase operation?

A

git rebase –abort

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

How do you continue a rebase operation after resolving conflicts?

A

git rebase –continue

17
Q

How do you show the common ancestor of two branches?

A

git merge-base branch1 branch2

18
Q

How do you push a new branch to a remote repository?

A

git push -u origin branch_name

19
Q

How do you delete a remote branch?

A

git push origin –delete branch_name

20
Q

How do you list all branches that have been merged into the current branch?

A

git branch –merged

21
Q

How do you list all branches that have not been merged into the current branch?

A

git branch –no-merged

22
Q

How do you create a branch at a specific commit?

A

git branch branch_name commit_hash

23
Q

How do you set the upstream branch for the current branch?

A

git branch –set-upstream-to=origin/branch_name

24
Q

How do you cherry-pick a commit from another branch into the current branch?

A

git cherry-pick commit_hash

25
Q

How do you show the branches that are ahead or behind their upstream branches?

A

git branch -vv