Lecture 14 and 15: Revision Control and git Flashcards
What is revision/version control?
Mechanism for managing changes made to files
Supports collaboration
What is a centralized model?
Single authoritative repository
All code checked in/out from this location
Single source of version history
Local changes aren’t “versioned”
What is a distributed model?
No authoritative copy, only working copies
Each repository (copy) contains all branches and revision history
Common operations are fast
Communication only occurs when sharing changes
Push/pull changes
Delta vs. snapshot storage
Delta stores each files’ changes individually, only changes made since last backup
Snapshot stores all files’ states at any given point
What is the general git workflow?
git config, git init (working repository), git clone (creates complete copy of the repository locally)
What is the working directory?
Refers to the currently checked out version of the project
This is where you work
Tracked vs. Untracked
Tracked files are in the last snapshot (unmodified, modified, staged)
Untracked is everything else
All files are tracked and unmodified in an initial clone
What are the tracked states?
Committed: Exists in local repository, usually pointed to by HEAD
Staged: Marked for the next commit, stored in the Index
Modified: File has changed, but not committed nor marked
What does git status do?
Shows the state of the working tree
What does git add do?
Begins tracking a new file
Stage files for commit that have been modified
Adds the file to the Index
What does git restore do?
Unstages a file
What does git commit do?
Record changes in the repository (move index to repository)
What is branching with git?
Allows you to work without interfering with the main code. Isolate changes, allowing for experimentation
What is merging with git?
Checkout the branch you want to merge onto
Merge the other branch
Resolve conflicts
How to work with remote with git?
Fetch: Obtain changes
Merge/Pull: Fetches and merges
Push: Push changes elsewhere