Git Flashcards

1
Q

What is the Git directory?

A

Where Git stores the metadata and object database for your project.

What is copied when you clone a repository from another computer

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

What is a working directory?

A

A single checkout (co) of one version of the project

Pulled from the Git directory to be used or modified

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

What is a staging area?

A

a file, generally contained on your Git directory, that stores information about what will go into your next commit

Also referred to as the index

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

Git Workflow

A

1- Modify files in your working directory
2- Stage the files - adding snapshots of them to your staging area
3- Do a commit which takes the files as they are in the staging area and stores the snapshot permanently to your Git directory

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

States:

A

1- committed - it is in the Git directory
2- modified - has been changed since it was checked out but has not been staged
3- staged - has been modified and added to the staging area

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

The 3 main sections of a Git project

A

1- The Git directory
2- The working directory
3- The staging area

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

How do you create a new git repository from an existing project?

A

Go to the project directory and type

git init

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

what does git init do?

A

creates a new subdirectory called .git

that contains a git repository skeleton

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

How do you get a copy of an existing git repository?

A

git clone [url]

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

what are the possible states that a file in your working directory can be in?

A
  • tracked

- untracked

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

What are tracked files?

A

files that were in the last snapshot

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

What states can tracked files be in?

A
  • unmodified
  • modified
  • staged
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what are untracked files?

A

anything in your working directory that were not in your last snapshot and are not in your staging area

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

when you first clone a repository, in what state are all of the files?

A

tracked and unmodified

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

how do you determine which files are in which state?

A

git status

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

what is meant by “working directory clean”?

A

no tracked and modified files

17
Q

what is an untracked file?

A

a files that was not in the previous snapshot (commit) and has not been “added” using git add

18
Q

how do you know that a file is staged

A

git status

shows it as “changed to be committed”

19
Q

what is
git add
used for?

A

1-to begin tracking new files
2-to stage files
3-marking merge conflicted files as resolved

you can think of it as: “add this content to the next commit” or “stage this file”

20
Q

what are the two columns in short status

status -s

A

1- the first column indicates whether the file is staged

2- the second column indicates whether it has been modified

21
Q

short name for a git repository

A

repo

22
Q

How do you initialize a new git repo?

A

git init

23
Q

how do you add all of the project files to the current git repo?

A

$ git add -A

  • this adds the files to the git staging area
  • adds all of the files in the current directory except those that match the patterns in a file called .gitignore
24
Q

what command will tell you all of the files in the staging areaz/

A

$ git status

25
Q

How do you tell git to keep the changes in the staging area?

A

$ git commit -m “initialize repository”
(use the-m flag to add a message -some current tense name)
-if you omit -m, git will open the system’s default text editor and have you enter the message there
-note: git commits are local on the machine on which the commit occurs

26
Q

How do you push changes to a remote repository?

A

$ git push

27
Q

how do you get a list of your commit messages?

A

$ git log

28
Q

bitbucket

A
  • a site optimized for hosting and sharing git repositories
  • this makes a full backup of your code
  • makes the code available for sharing
29
Q

what is a branch?

A
  • a copy of the entire repository

- usually the parent repository is the master branch

30
Q

How do you create a new branch?

A

-a branch is a copy of the complete repository where you can make changes without modifying the parent files
$ git checkout -b modify-Readme
-this switched to a new branch called ‘modify-README’

31
Q

how do you add bitbucket as the origin for your repository and then push your repository up to the remote origin?

A

$ git remote add origin git@bitbucket.org:smartinconsult/hello_app.git
$ git push -u origin –all

this pushes up the repo and its refs for the first time

Ruby tutorial p. 36

32
Q

how do you see a list of branches that you have?

A

$ git branch

lists all the local branches and identifies the current branch with an asterisk