GIT Flashcards
Git Project Layout
Working Directory: Space for Unmodified/modified files
To bring to Working Dir from GIT Dir need to CHECKOUT Project
Staging Area: Space for Staged Files
To go to STAGING AREA from WORKING DIRECTORY you STAGE files
GIT Directory
STAGING ===> GIT Directory is COMMIT Files
Working directory sometimes called the “working tree”
Staging Area sometimes called the “index”
git checkout updates files in wokring directory to match version in the index or specified
Git Project Layout
Working Directory: Space for Unmodified/modified files
To bring to Working Dir from GIT Dir need to CHECKOUT Project
Staging Area: Space for Staged Files
To go to STAGING AREA from WORKING DIRECTORY you STAGE files
GIT Directory
STAGING ===> GIT Directory is COMMIT Files
Working directory sometimes called the “working tree”
Staging Area sometimes called the “index”
git checkout updates files in wokring directory to match version in the index or specified
passing the git add command will add changes made to the files in staging area to the respository
GIT Status: Show the status of files in the directory
this checks the current status of the respository
it will report things like if there is nothing currently pending to be send to the repository or if there was a recent commit that looks like the current version of the code. Git status will display files with such changes because they are different from those in your most recent commit in your git repository.
Use git status to continue to monitor state between the repository and the working directory
git reset
resets the staging area, returning files to working tree
removes all files from the staging area
git rm
removes files from the workig directory and from being tracked
what is the difference between git and gitHub
git is a open-source tool for managing a repository. GitHub is a commercial entity that uses git.
Not required to use GitHub to use git
For updating local repository, what is the difference between git pull and git fetch
git fetch updates your local repository with all available remote branches
git pull performs a fetch and then merges the current branch into the appropriate remote branch
git checkout
this above command will transition a file called myfile.c from modeifed to unmodified without commiting it
command can be used ti discard changes
For updating local repository, what is the difference between git pull and git fetch
git fetch updates your local repository with all available remote branches
git pull performs a fetch and then merges the current branch into the appropriate remote branch
(git pull = git fetch + git merge)
To setup line ending preferences
git config –global core.autocrlf input
git config –global core.safecrlf true
Lab question: After staging changes with the “git add” command, what output do you see when checking the status of the working directory?
This means changes made have been temporarily staged but not recorded to the repository. The next commit operation will include staged changes
If at some point, user decides to not want to comitt that change, run GIT RESET command and it will unstage that change
What’s the point of staging files?
A separate staging step allows you to specify which modified files you actually want saved to your git repository, and which modified files you don’t want to save yet. It also allows you to bundle files as whole versions (so if you have 5 files staged that you commit, they are considered part of a single version).
By separate staging and committing, you have the ability to easily fine tune what goes into each commit
git commit
command to bundle up all the staged files, treat them as a single version, and save them into the git repository
the -m flag will allow to give a comment on the command line. commit command will allow you to interactively edit a comment for the commit
if -m is omitted from the command line, it will pop you in to the editor of choice so user can comment to the commit
default is VIM
ever file is given a hash to help track files
Most source control system work with files. Files are added to source control and the system will track changes to the file from that point on
Git focuses on the changes to a file rather than the file itself.
Running the ‘git add file’ command will have git make a note of the current state of the file to be committed later
git init
initialize repository