Committing Atomic Changes Flashcards

1
Q

What is version control?

A

Version control or source code management tools or revision control system take on the task of keeping a software system consisting of many versions and configurations well organized. Version control tracks every iteration of your product or application, basically a log of your history and versions of software.

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

How to install git?

A
  1. ) To install git simply run $ sudo dnf install git-all.
  2. ) Set the username to identify your repository $ gitconfig - -global user.mail myemailaddress@aol.com
  3. ) You may want to set the editor you’ll be working in $ git config - -global core.editor “subl” -w
  4. ) You may want to set some coloe to your interface. Run $ git config - -global color.ui true.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If git is installed how would you go about creating a new repository on your computer?

A

Create a new folder and inside the folder run $ git init.

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

Inside every repo you create there’s an invisible .git folder that’s developed. What kind of files might you see if you opened that .git folder?

A

You should see HEAD, config, hooks, objects, branches, description, info, refs. Each file is critical to know and be familiar with if you want to master git.

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

Most version control systems have 2 tree architectures: a working directory and a repository. What about Git?

A

Git has a 3 tree architecture: working directory, staging index, repository. Think of the workking directory as the work on your local computer.

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

When you go through with a commit one of the major things the computer does with your commit is to assign what to your commit?

A

Git gives that commit a checksum #. The top of your commit chain will always have a HEAD pointer indicating the most recent commit or a pointer to the current branch reference. This reference later becomes a pointer to the proceeding/new branch.

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

What command would you run to see your commit history?

A

$ git log

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

What command would you run to show the difference between the last commit and a recent commit?

A

$ git diff

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

What would $ git diff - -staged do?

A

git diff - -staged will show you only the changes made to the files in the staging index.

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

What command do you use to remove a file from your repo?

A

$ git rm file.txt

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

How do you rename a file in your repository?

A

$ git mv firstName.txt newName.txt

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

How would you go about undoing changes on a branch after you’ve just written new code and want to revert back to the old code?

A

$ git checkout. This pulls your latest commit and ignores any changes you have in your working directory.

$ git checkout would pull your branch and allow you to start working on it.

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

How do you unstage things?

A

$ git reset or $ git reset HEAD ( both of these reset staging to the last commit ), just after you add a file to the staging index, if you added the file already reset would not work.

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

How to amend your last commit message?

A

https://www.atlassian.com/git/tutorials/rewriting-history

$ git commit ammend -m “this is an updated commit”

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

How do you define a git alias?

A

$ git config - -global alias. ;
$ git config - -global alias.unstage ‘reset HEAD –’
$ git config - -global alias.civ ‘commit -v’;
$ git config - -global alias.ci commit
$ git config - -global alias.st status;

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

How would you use git add

A

https://git-scm.com/docs/git-add

git add is used to start the process of updating your project version. You might say git add . (all), or git add -p, or git add -A (all), git add - -all (you guessed it!).

git add patch is a way for us to select chunks of changes we want added to our index one at a time rather than all at once.

17
Q

What does git checkout - -patch do?

A

git checkout - -patch
git checkout -p

We know git checkout helps us switch branches but if we run git checkout -p we do NOT switch branches, instead we update the named paths in the working tree with files from a tree-ish or a particular commit/tree.

18
Q

Explain the differences between the git HEAD, work tree and Index! Also what is the local repo and remote repo?

A

https://stackoverflow.com/questions/3689838/difference-between-head-working-tree-index-in-git

  • > The working tree is the work on your computer.
  • > The index represents a staging area or checkpoint of sorts.
  • > The local repo is the repository we commit our messages to and if your local repo is master it is master.
  • > The remote repo is a repo which exists on a different computer, it could be the master repo and it might not be. If you had changes on your local repo you might either push it to master or have someone merge it to the master repo.