git ch. 0-3 Flashcards
What is git?
Command-line tool for managing version control.
Light, efficient, safe/easy recovery, open source.
What is a git repository?
History of project’s versions, files, branches.
What is a commit in git?
History of snapshots of your project.
Contains file contents, metadata, parent pointer(s), and unique commit ID hash.
What is the structure of commit history?
Forms a directed acyclic graph (DAG).
Where is the git repository stored?
Stored locally.
What is the working directory in git?
Where you directly interact with project files. Looks like local version of project.
Modifying a file will move it from unchanged to changed working directory.
What does ‘git add’ do?
Stages changes. Moves things from working directory to staging area.
What is the staging area in git?
Where changes are prepared before committing.
Also known as the index.
What does ‘git commit’ do?
Saves snapshot and moves it from staging area to committed history. Moves head pointer to most recent commit.
What is the relationship between working directory, staging area, and committed history?
Working directory -> git add -> staging area -> git commit -> committed history.
What does HEAD represent in git?
Current working branch.
What is the purpose of ‘git switch’?
Causes HEAD to point to a targeted branch.
What is a detached head state?
When HEAD points to a specific commit instead of a branch.
What is a source branch?
Branch with new changes.
What is a target branch?
Branch being merged into (e.g., main).
Must switch to this branch first.
What is a fast forward merge?
Linear path of commit history. Source branch hasn’t diverged from target branch.
What is a merge commit?
Diverged path where both source and target have new commits.
Creates new commit with 2 parent commits.
What indicates conflicting changes in a merge conflict report?
««««<, ===========,»_space;»»»»».
How can you see which files have conflicts?
Use ‘git status’.
What does ‘git help [command]’ do?
Provides help for the specified command.
What does ‘git config’ do?
Tells git what your name and email is.
git config –global user.name “name”. (the –global indicates that this is applied to all projects)
What does ‘git init’ do?
Turns directory into git repository.
What does ‘git status’ show?
Shows branch, commits, untracked files, tracked files.
What does ‘git log’ do?
View repo commits, outputs each commit’s id hash, author, date, and message.
What does ‘git log –graph –oneline’ do?
Visualizes commit history with branch relationships.
What does ‘git stash’ do?
Temporarily stashes away changes to focus on other tasks or branches.
What does ‘git stash pop’ do?
Recovers stash changes to current working directory.
What does ‘git restore’ do?
Undo file change.
you missed this on your first qz00 try
What does ‘git restore –staged [file]’ do?
Unstage changed file.
What does ‘git checkout [commit hash] – [file]’ do?
recovers a file from its previous commit
What does ‘git checkout [commit hash]’ do?
temporarily view or test a specific commit without creating a new branch
this is in a detached head state
What does ‘git checkout [branch]’ do?
Switches to specific branch.
What does ‘git checkout -b [new branch name]’ do?
Creates and switches to new branch.
What does ‘git branch’ do?
Create, list, delete branches.
git branch -c [name] creates. git branch lists. git branch -d [name] deletes.
What does ‘git branch -d’ do?
Safe delete merged branches.
What does ‘git switch’ do?
Switch between branches.
What does ‘git switch –create [branch name]’ do?
Creates and switches to new branch.
What does ‘git merge’ do?
Combine changes from one branch into another.
What does ‘git merge –abort’ do?
Cancel merge and return to pre-merge conflict state.
echo [message]»_space; [file]
appends text to file contents without overwriting
git restore [file]
gets rid of changes in working directory for the file
what are the different ways to create branches?
git switch -c [branch name] OR git checkout -b [branch name]. git branch [name].
git config –list
verifies current configuration. shows all variables in config file, like user.name and user.email
what are branches, conceptually
pointers to commits that update as new commits are added (depending on HEAD)