Git Flashcards
What is the Git directory?
Where Git stores the metadata and object database for your project.
What is copied when you clone a repository from another computer
What is a working directory?
A single checkout (co) of one version of the project
Pulled from the Git directory to be used or modified
What is a staging area?
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
Git Workflow
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
States:
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
The 3 main sections of a Git project
1- The Git directory
2- The working directory
3- The staging area
How do you create a new git repository from an existing project?
Go to the project directory and type
git init
what does git init do?
creates a new subdirectory called .git
that contains a git repository skeleton
How do you get a copy of an existing git repository?
git clone [url]
what are the possible states that a file in your working directory can be in?
- tracked
- untracked
What are tracked files?
files that were in the last snapshot
What states can tracked files be in?
- unmodified
- modified
- staged
what are untracked files?
anything in your working directory that were not in your last snapshot and are not in your staging area
when you first clone a repository, in what state are all of the files?
tracked and unmodified
how do you determine which files are in which state?
git status
what is meant by “working directory clean”?
no tracked and modified files
what is an untracked file?
a files that was not in the previous snapshot (commit) and has not been “added” using git add
how do you know that a file is staged
git status
shows it as “changed to be committed”
what is
git add
used for?
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”
what are the two columns in short status
status -s
1- the first column indicates whether the file is staged
2- the second column indicates whether it has been modified
short name for a git repository
repo
How do you initialize a new git repo?
git init
how do you add all of the project files to the current git repo?
$ 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
what command will tell you all of the files in the staging areaz/
$ git status