Source Control - Git Intro Flashcards

1
Q

Keywords: Version Control

A

AKA source control, the practice of tracking and managing changes to software-code.

version control tools help software teams manage changes to source code over time.

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

Keywords: Git

A

Distributed Version control system that tracks changes in any set of computer files, usually for coordinating work among programmers collaboratively developing source code during software development. meant to amp speed, data integrity, and support for distributed, non-linear workflows.

open source version control system

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

Keywords: Repository

A

tracks and saves the history of all changes made to the files in a Git project.

Collection of files of various different versions of a Project

The repository is the .git hidden folder inside the workind directory. the working directory is essentially your project folder.

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

Keywords: 4. Git HEAD

A

“active” or “current” branch. only one branch can be checked out at a time - at said time, called the HEAD branch.

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

Keywords: 5. Working directory

A

The Workind Directory is a single checkout of one version of the project.

This means if you checkout a branch and are sat on a commit, your working directory is the “umbrella” term for all your files and folders.

“all your files and folders”. contains the .git file (repository)

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

Keywords 6. Staging Area

A

If the working area is where files are not handled by git, then Staging Area is files that are going to be part of the next commit, which lets git know what changes in the file are going to occur for the next commit.

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

Keywords: 7. Commit Object

A

a snapshot is a commit.

A commit object includes a pointer to the main tree (root directory) as well as other meta-data such as the commiter, a commit message and the commit time.that represents a snapshot of the contents of the working directory at a certian point)

The commit object stores the hash of the tree object (

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

Keywords: 8. Branching

A

Git Branches are a pointer to a snapshot of your changes.

When you want to add a new feature or fix a bug you spawn a new branch to encapsulate your changes. The branches can be merged back into the main/master branch when ready.

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

Commands 1: init

A

Create empty Git repo in specified directory. Run with no arguments to initialize the cuurrent directory as a git directory.
git init <directory></directory>

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

Commands 2: add

A

git add <directory></directory>

Stage all changes in <directory> for the next commit. replace <directory> with a <file> to change a specific file.</file></directory></directory>

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

Commands 3: commit (-m)

A

git commit -m “<message>"</message>

Commit the staged snapshot, but instead of launching a text editor, use <message> as the commit message</message>

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

Commands 4. status

A

git status

List which files are staged, unstaged, and untracked.

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

Commands 5: diff

A

git diff HEAD
git diff –cached

Show differences between <working>/<staged> and last commit.</staged></working>

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

Commands 6: mv

A

git mv [<options>] <source></source>... <destination></destination></options>

Move or rename a file, directory or symlink

-f force
-k skip move or rename actions that cause errors
-n do nothing
-v verbose (report file names as they move

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

Commands 7: rm

A

remove files from the working tree and from the index.

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

Commands 8: log

A

git log
show the commit history for the currently active branch.

(only current branch)

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

Commands 9: clone

A

git clone [url]
retrieve an entire repository from a hosted location via URL

18
Q

Commands 10: remote

A

git remote -v
List the remote connections you have to other repositories.
-v includes the URL of each connection

19
Q

Commands 11: push

A

git push [alias] [branch]
Transmit local branch commits to the remote repository branch

20
Q

Commands 12: pull

A

git pull
fetch and merge any commits from the tracking remote branch

21
Q

Commands 13: fetch

A

git fetch [alias]
fetch down all the branches from that Git remote

22
Q

Commands 14: config

A

git config –global user.name “[firstname lastname]”
git config –global user.email “[valid-email]”
git config –global color.ui auto

configuring user information sued across all local repositories

23
Q

Commands 15: ignore

A

no explicit ignore command.

rather, .gitignore file must be edited and committed by hand when you have new files that need to be ignored.

24
Q

Commands 16: reset

A

git reset [file]
unstage a file while retaining the changes in working directory.

25
Q

Exercises 6. https://git.infinitylabs.co.il/ilrd/haifa/hdo01/daniel.habber.git/
what is this command good for?

A

creates a convenient pointer a very, very inconvenient url repository

26
Q

Exercise 12/13 undo git add

A

git reset
git reset HEAD~

27
Q

Exercise 14.d, explain the following gcc flags

A

-ansi: turns off GCC features that are incompatible with ISO90 (will not cause non-ISO programs to be rejected)
-pedantic errors: gives an error when base standard (Wpedantic) requires a diagnostic, like undefined behaviour at compile time
-Wall: enables all warnings about constructions that some users considers questionable
-Wextra
-g
-DNDEBUG
-03

valgrind –leak-check=yes
valgrind –track-origins=yes

28
Q

Q1 What are the benefits of using version control systems?

A

having the option to collaborate on a single project from multiple remote locations,

and the ability to return to a previous functional version before accidentally ruining the whole project

29
Q

Q2 Which files belong to the Git repository? Which files do not?

A

effectively the .git folder. Collection of files of various different versions of the project

30
Q

Q3 Why do we need .gitignore?

A

.gitignore allows the ability to remain up to date with the git repository in terms of pushing and pulling, but continue to work on sensetive or otherwise incomplete code that should not be merged into the main branch yet.

31
Q

Q4. Explain each step in the workflow of tracking changes to a repsository

A

git pull > can merge or rebase the ‘master’ branch, or whichever chosen branch, into the local repository.
git add . > adds local changes to the staging list,
git commit > writes changes from the staging area to the local repository, permanently.
git push > ya yeets the local repository back into the main branch, or whichever branch of choice.

32
Q

Q5 What is the difference between git fetch and git pull?

A

while git fetch only downloads changes to your local repository, git pull downloads the changes AND merges them into your local branch (runs git fetch and git merge)

Use git fetch to be able to see changes between local repository and main/other branch,
git pull makes sudden, possibly unexpected changes.

33
Q

Q6 What is a commit in Git? How is it different from saving a file?

A

git commit creates a snapshot of the staging directory to the respositories commit history. you can technically cycle back to a different snapshat, each snapshhot is a collection of the files in their current state at the time of the snapshot

34
Q

Q7 How often should you commit?

A

as often as you have made satisfying, functional code that you feel you would want too come back to if something goes wrong

35
Q

Q8 What is the difference between the HEAD and the master?

A

HEAD is a reference that points to the master. MASTER is a reference to the latest commit. HEAD and master point to the latest commit whenever you commit by default.

HEAD isn’t necessarily the latest revision, it’s the current revision. (HEAD tells us which branch we are working on)

36
Q

Q9 How do you refer to a specific commit?

A

run git log to find the SHA1 identifier of the specific commit,
then checkout the target commit.

git checkout 45asdf987fdg4sdiu

37
Q

Q10 What happens when you clone a git repository?

A

cloning pulls down a copy of all the repository daat that GitHub.com has at that point in time, including all versions of every file and folder for the projecy. You can then push and pull changes from that directory.

38
Q

Q11 Explain the outcome of the following commands:
mkdir rep;
cd rp;
git init;

A

after creating a rep fil and moving into it, git init initializes a git repository (.git directory), containing all the necessary Git metadata for the new repository. (subdirectories for objects, refs, and template files).

HEAD file is created pointing to the currently checked out commit.

39
Q

Q12 What is the difference between git reset –hard and git reset –soft?

A

soft reset: moves the HEAD back to the specified commit, and un-stages every file that was added to be staged between the current state and the specified commit.
hard reset: destroys all changes and removes them from the working directory, staging area and commit history.

40
Q

Q13 How would you search through your project for a string or regular expression?

A

git grep STRINGORREGULAREXPRESSION

41
Q

Why would DevOps people need to be familiar with git?

A

because good gods it’s great for working on a single project simultaniously as a group and at different times,

and good gods can it make rapid changes remotely, quickly, and deliver them without running around in a car and a USB stick.