Module 2 Flashcards

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

What does HEAD represent in Git?

A

The currently checked-out snapshot of your project

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

What is the purpose of the git checkout command?

A

It reverts changes to modified files before they are staged.

It will revert to state from HEAD.

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

What is the gitignore file

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

What is the purpose of the git checkout -p command?

A

It allows reverting specific changes only. Git will go through change by change and ask if I want to revert.

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

What is the purpose of the git reset command?

A

It reverts changes to modified files after they’ve been staged.

It will revert to state from HEAD.

output.txt was incorrectly stagged by the git add * command

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

How to use the git reset command?

A

git reset HEAD <file name>

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

How to use the git checkout command?

A

git checkout <file name>

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

What does the git commit --amend do?

A

Overwrite the previous commit.

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

When git commit --amend should not be used? Why so?

A

Avoid using it when commit has been pushed to a public/shared repository. It is acceptable only for local repositories.

The reason is that git commit --ammend will overwrite previous commit and can lead to confusing situations when collaborating with others on the same code.

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

What does the git revert do?

A

It creates a new commit with inverse changes.

Git does not delete the problematic commit as this would mean we would lose track of project history.

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

How to use git revert?

A

It is good to add the reason for the rollback on the commit message.

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

How to revert to a commit other than the previous one?

A

Use the commit ID as argument instead of HEAD
~~~
git revert abb063210c1f011b0d6470a4c5f1d8f672edd3ef
~~~

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

How does Git ensure the commit ID is unique to each commit?

A

It uses the SHA1 algorithm to create a hash that takes into consideration the commit message, date, author, and the snapshot taken of the working tree.

Therefore, the chances that two different commits have the same hash is virtually impossible and if it does happen, it is an indicator that something went wrong (e.g. tampering with the repository)

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

What does the git checkout -b new branch command do?

A

Creates a new branch and switches to it.

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

How does git checkout switch branches?

A

By updating the working tree to match the selected branch.

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

What happens when we merge two branches?

A

Both branches are pointed at the same commit.

16
Q

What is the purpose of organizing repositories into branches?

A

To enable changes to be worked on without disrupting the most current working state.

17
Q

How do I know in which branch am I currently?

A

Use git branch and look for the branch preceded by an asterisk *

Currently in the master branch in this example

18
Q

Is is possible to delete a branch?

A

git branch -d <branch_name>

In case there are changes not commited, Git will ask us to confirm if we still want to delete it.

To overwrite this step, use git branch -D <branch_name> instead.

19
Q

What’s the advantage of Git throwing a merge conflict error in cases of overlap?

A

It prevents loss of work if two lines overlap.

20
Q

When we merge two branches, one of two algorithms is used. If the branches have diverged, which algorithm is used?

A

Three-way merge

21
Q

What command would we use to throw away a merge, and start over?

A

git merge --abort

22
Q

What is the purpose of a Git repository, and how does it facilitate version control?

A

A Git repository is a version control system that tracks changes to source code, allowing multiple developers to collaborate, review changes, and maintain a complete history of project revisions.

23
Q

In a Git repository, what command would you use to create a new branch based on the current branch, and what command would you use to switch to that newly created branch?

A

To create a new branch, use git branch new-branch-name, and to switch to it, use git checkout new-branch-name

24
Q

What is the primary purpose of merging a branch back into the main branch in a Git repository?

A

To combine the changes from the branch into the main codebase