Introduction Flashcards

1
Q

What is a Version Control System (VCS)?

A

It is a system that allows me to keep track of changes made to files. It is especially powerful for keeping track of text files, but it can be extended to configuration and data files as well as documentation.

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

What is a commit?

A

Commit is a collection of changes made to one or more files from a project at any given time,

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

What means for Git to be a distributed VCS?

A

It means that each contributor to a particular Git repository has its own local copy of this repository. The tracking and merging of changes to the repository do not require a central, coordinating server.

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

What are the two commands to create a Git directory on my machine:

  1. creating from another remote repository
  2. starting from scratch on my machine
A

Open the Terminal, navigate to the directory where I would like to put the Git directory and run one of those commands below

  1. git clone [insert URL]
  2. git init
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the three main elements when using Git?

A
  1. Git Directory
  2. Stagging Area (or Index)
  3. Working Tree
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain how a simple Git workflow works, from creating a new file/making changes to an existing one to finally committing it to the Git directory.

A

Start: create a new file on the Git directory or modify an existing one

In order for these changes to be tracked, I need to add this file to the Stagging Area.

Finally, I need to commit the content of the Stagging Area to the Git directory in order to capture the current state of the project at this moment in a commit.

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

Explain the Git Directory

A

Git Directory is a directory that will contain all the files that constitute a project as well as the history of the changes made to these files. Each snapshot of the project at any given time is called a commit.

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

Explain the Stagging Area, also called Index

A

The Stagging Area is a file that stores the information (i.e. files) that will constitute the next commit.

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

Explain the Working Tree

A

The Working Tree is a directory that exists outside of the Git directory and that contains the current version of the files in which I am working at. It can be viewed as a SANDBOX where I can do development until files are ready to be committed.

The Working Tree contains both the tracked and untracked files.

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

Explain the flow of the status of file in a Git workflow

A
  1. File usually starts at a modified stated (or in some cases as a new file)
  2. By using git add, the status of the file changes to stagged
  3. Finally, by using git commit, the status is ultimately changed to commited
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the output from the command below?

$ git status

A

It will show the status of both the Working Tree and the Stagging Area, eventually showing the status of both tracked and untracked files.

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

If I navigate to the Git directory and run the command below, what would be the output?

$ ls -la .git/

Explain the -la

A

Output will be the content of the Git Directory (folder)

  • l (will show the long format for the output)
  • a –> will show all files (even the ones hidden)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to use the diff command to check the difference between the following two files?

script.py

script_reviewed.py

A

diff -u [reference file name] [new file name]

$ diff -u script.py script_reviewed.py

The -u argument is related to the format of the output

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

How to create a .diff file with the changes between the following two files?

script.py

script_reviewed.py

A

$ diff script.py script_reviewed.py > script.diff

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

How to apply changes to my reference file from a .diff?

reference file: script.py

script.diff

A

$ patch script.py < script.diff

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

What is an example of a simple, but effective, structure of a commit message?

A

First, there should be a BRIEF description of the change, i.e. no more than 50 characters. Suggestion: Write it, along with the rest of your message, in the imperative tense: “Fix bug” and not “Fixed bug” or “Fixes bug”.

Insert a blank line

Then, there should be 1-2 paragraphs explaining the change in detail. Remember to keep each line shorter than 72 characters to ensure it is displayed correctly on the Terminal. There must be an underlying problem that motivated you to do this work. Convince the reviewer that there is a problem worth fixing and that it makes sense for them to read past the first paragraph.

17
Q

How to get the current configuration of a Git repository?

A

$ git config -l

18
Q

What happens if I try to create a commit without a commit message?

A

Git will abort the operation and will not allow me to proceed with the commit unless I provide a message.