Getting Started with Git Flashcards

1
Q

What is version Control?

A

A way to track code changes.

Allows us to see all of the changes made to code over time and go back to previous versions of the code (like a backup).

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

What is Git Branching?

A

AbranchinGitis simply a lightweight movable pointer to one of the commits made to your code.

Each individual branch has no way of seeing or knowing what other changes have been made to any other branch - only keeps track of changes in its own branch.

Can also be used for fixing any defects or bugs, where you can fix the bug in a branch and then merge the code back to the main branch.

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

What is a Merge Conflict?

A

Happens when Ex) you’re writing a bunch of code on your own branch, and other people write code on their branches, and the main/master branch is getting updated at the same time by multiple different people and code.

The Branch won’t know which code to keep or which commit to have as the latest pointer.

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

Is Git a centralized or distributed Version Control System (VCS)?

A

Distributed.

Allows us to maintain a full copy of the code repository on every system i.e Every person working on the repository has a full copy of it – multiple full clones of the entire record, where they can work on the code themselves and commit changes locally.

They can then upload these changes

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

If Git in a distributed VCS, how does GitHub work?

A

GitHub is a cloud-based central repository where people can modify and upload their versions of work on the source code to a central Hub.

If the Hub/Repository goes down, any of the cloned copies that people pull to their local workstations can become the designated Master copy.

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

What is a Git Repository?

A

A collection of files that Git tracks the changes for/to.

You can create a repo from scratch or you can clone one from a repo that you have access to (perhaps held on Github)

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

Is it best practice to make a lot of modifications to code and then stage + commit it?

A

NO - Many commits that are small, and focused in nature is BEST PRACTICE.

Commit messages should be short and to the point; if you make a lot of changes, you should make it a practice to make small/short commits with precise messages so that you can revert back individual changes themselves.

This allows you to get much more granular with those changes.

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

What is Git Diff?

A

Powerful command that will look at 2 different files and compare what is different between the two and present it in a way that’s easy to understand.

Typically used to point to the same file at 2 different points in time. This way if you have thousands of lines of code, you’re only seeing what’s relevant + a few lines before and after the highlighted change.

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

SUMMARY: Git Commands/Actions

→ we track the changes inside of our repo with Git Commit

→ We can look at the history of commits with the Git Log

→ We can look at the changes between files, or how files have changed over time with Git Diff

A

→ We can use the Git Checkout command to revert the working directory (whichever branch you are in) to match a specific commit i.e go to a commit at a specific point in time.

→ Git Amend - option on the git commit command to replace the previous commit; typically used when you just made a commit, but need to make some quick changes; good for quick fixes

→ Git Revert - creates reverse commits, but preserves all history

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

What is the “.gitignore” file? What is it used for?

A

Git allows us to ignore certain files with the addition of the .git ignore file into a repo. We can add files to the list of items we DONT want git to track.

There can end up being a lot of files in the source code folder that you just don’t want to track and/or store any longer inside the Git Repo; config files, notes, temporary files, etc. that don’t need to be shared or tracked at all

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