Branches Flashcards

1
Q

What is a “branch”?

A

Branches to create development “branches”. Ideal for creating features separately and then adding them to the main branch.

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

What is the new default branch name when you create a project through GitHub?

A

main

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

What is the command to create a new branch?

A

git branch <branch_name>

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

What is the command to switch branches?

A

git checkout <branch>

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

What is the difference between the git branch and git checkout commands?

A

git branch is used to create new branches, git checkout is used to change branches

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

How do we delete a branch?

A

git branch -d <branch>

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

What does this command: git checkout -b <branch>?

A

Exit of the actual branch, creates a new and goes to the new branch

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

Usually, will we use the command git merge from which branch?

A

main

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

Complete the following command:

git merge …

A

<branch>

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

What is the command to list all branches?

A

git branch

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

Complete:

Files created in a branch […]

A

are associated with this branch

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

Alias for

git push –set-upstream origin <branch_name>

A

git push -u origin <branch_name>

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

If we don’t have a branch in Github, how can we push our local changes only for this branch in Github?

A

We type the command git push –set-upstream origin <branch_name>

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

Where does the branches live?

A

In the Local and Remote repository

Not in Working directory or staging area

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

Pointer that points to the current branch and commit you are currently at.

A

HEAD

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

When we do checkout to a branch that name matches with a remote branch …

A

We will get a new local branch that is linked to the remote branch

17
Q

Why when we create a new local branch, we need to type git push -u origin \<branch_name\>?

Or git push --set-upstream origin \<branch_name\>

A

Because this local branch doesn’t have a “link” to any remote branches.
This command will create a new remote branch with this name and link our local branch to the respective one branch