Version control Flashcards

1
Q

What is version control?

A

A system for managing changes to documents, programs, web pages

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

Why do we need version control?

A

Keep track of a revision history/versions of a document, enable users to collaborate on a collection of documents

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

Other version control systems other than Git?

A

rcs, cvs, subversion, mercurial

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

What are the 3 types of version control?

A

Local, centralized, distributed
They differ in how the version database is stored.

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

Local vs centralized?

A

For local, there is no server involved. The version database is stored locally. Only the local computer can checkout the file.

For centralized, there is a central server and each computer checks out the file from this server to get a local copy of the file on their own computer.

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

Centralized vs distributed?

A

For centralized, there is one server that saves the version database, no users have the database on their computer.

For distributed, there is a server with the version database and each user has their own version database on their computer.

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

Which VCS stores differences?

A

mercurial

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

Which VCS stores snapshots?

A

git

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

Differences vs snapshots?

A

Differences is when a file is changed, the VCS only saves the changes as a new version (the difference between the previous version to current). If one file among all files is not changed in a version, the file is not updated. For example, if file A is changed, version 1 is only the changes in file A.

Snapshots is when a file is changed, all files are saved as a new version the way they are. For example, if file A is changed, version 1 becomes file A1, B, C.

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

Why is using differences inefficient?

A

Because every time we want the latest version of a file, we need to start from the initial file and apply all the changes along the versions.

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

Describe the common git workflow.

A

git init/clone, git add, git commit, git push, git pull (git fetch + git merge)

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

Does git use a three-stage architecture?

A

Yes

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

Describe the three-stage architecture of Git.

A

The 3 stages are: working directory, staging area, local repository (.git repository)

Working directory is where the actual project files are located. Any changes made to files here are untracked. To get to staging area, we use “git add”.

Staging area is an intermediate step between the working directory and .git repo. We basically store everything we want to commit in the next commit here. To get to the .git repo, use “git commit”.

.git repo is like a container for Git’s VCS. It stores committed snapshots, the project’s history, and facilitate with Git operation. To move the files to the remote repo, use “git push”.

Commands to interact with the remote repo: git pull, git push, git clone, git fetch

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

Relationship between blobs, trees, and commits?

A

Each commit has a unique commit id and a tree id of the tree it belongs to. A tree stores its own id and blobs ids. A blob is just an object type used to store file contents and each of them has an id. Can think of each blob as a file in our repo.

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

Is a commit a snapshot of the state of the project?

A

Yes

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

When does the blob id change?

A

When the file contents change (even by 1 byte). Each blob id refers to a specific version of a file.

17
Q

What algorithm is used to make commit ids?

A

SHA-1

18
Q

How many percent of a hash will change when you change a file?

A

50%

19
Q

How many digits of the 40 digits hash does git use?

A

First 8 digits

20
Q

What is git tag?

A

“git tag NAME” is a command we can use to give a name to a certain commit (kind of like a pointer)

21
Q

Where does HEAD always point to?

A

HEAD always points to the latest commit of the current branch. e.g. HEAD points to master, which is a branch, and master points to the latest commit id.

When there is a branch, we can imagine this branch has a pointer with its name and it points to the latest commit. Then HEAD points to the branch pointer.

22
Q

Should we touch the master branch? What should it be used for?

A

No. Only well-tested, stable commits. Usually only when we need to release to customers.

23
Q

Other than the master branch, what other branches do we usually use?

A

1) Development branch
2) Feature branches to test out things before merging into development
3) Release branches to store versions ready to be released
4) Hotfixes include bugs fixed. When a bug is detected and fixed, the development commits do not have this fix, so remember to add it to the dev branch. Then release a new version to customers via the master branch. Next time, when a version is added to the release branch, this bug fixed will be included.

24
Q

In a commit message, should the subject line be attached to the body?

A

No, there should be a blank line

25
Q

What is the word limit on the subject line in a commit message?

A

50 characters

26
Q

Should there be a period at the end of the subject line?

A

No

27
Q

What is the word limit on the body?

A

72 characters

28
Q

What is the body used to explain?

A

What and why, not how

29
Q

If we have the terminal, shell, OS, hardware, which part(s) of this is UNIX?

A

Shell and OS

30
Q

What is the terminal?

A

An interface to type commands to interact with the shell

31
Q

What does the shell do?

A

Interact with the OS using human readable commands

32
Q

cat file | head -n 20

A

It lists the first 20 lines of a file

33
Q

cat file | sort | uniq -c

A

Find all unique words in the file and their occurrences

34
Q

ls > output.txt

A

Save the output of the command into a file

35
Q

ls 2>&1 | tee output.txt

A

2>&1 redirects the output of stderr to stdout (combining with the existing stdout) and pipe the combined output. tee is used to write/display the output to both stdout and a file.

36
Q

cat file | grep mystring

A

Search for mystring in the file

37
Q

find [folder] -name “filename”

A

Search for a file in a folder