git
LEARning goals
- Describe what a version control system is and list the main advantages of using it
- List the main advantages of git over other version control systems
- Understand the file status lifecycle
-
Version control system. Definition and history.
-
What is git and its advantages
-
File status life cycle. From untracked to committed.
OUTLINE
VERSION CONTROL SYSTEM (VCS)
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.
Advantages of using a vcs
- Revert files or the entire project back to a previous state
We can experiment with new code without worrying of messing around something..
..and we don't need to backup!
ADVANTAGES OF USING A VCS
- Review changes made over time
We can read the history of a single file to understand how it evolved from the beginning
ADVANTAGES OF USING A VCS
- See who last modified something that might be causing a problem... and blame him!
Type of VCS
Directory based "VCS"
Yay ?
Easy to use
Doesn't require any learning process
Nay
Extremely ineffective
Extremely difficult to collaborate
Impossible to track changes
No remote backups
Many other reasons
Local VCS
Yay
Allow to track changes in the files
Nay
Cannot be used to collaborate
No remote backups
Centralized VCS
Yay
Allow collaboration
Access control
Central backup
Nay
Single point of failure
Painful merges
Requires internet connection
Decentralized VCS
Yay
Every clone is a fork
Every clone is a backup
No connectivity issues
Fast. Really!
Nay
Not good for large binary filesGit is an open source, distributed version control system designed for speed and efficency
GIT
Git design goals
-
Speed
-
Simple design
-
Strong support for thousands of parallel branches
-
Fully distributed
-
Able to handle larges projects like Linux kernel effectively
-
Ensure integrity
Tracking Changes
- A basic version of the file is saved
- Any modification to that file is saved separately
- When we want to retrieve a specific version of the project, all the single modifications are applied to the basic file, for all the file in the repository
Advantages
Disadvantages
Time inefficientTracking Snapshots
- A whole copy of a file is done when this is modified
- When we want to retrieve a specific version of the project, we just copy to the tree structure corresponding to that version in the working directory
Advantages
Extremely time efficient
Disadvantages
Space "inefficient"
..but it's not a problem if we mostly track text based files
Git is a file system
Git thinks of its data more like a set of snapshots of a mini filesystem.
Git advantages
Nearly every operation is local
-
Operations are very fast
- Every local repository is a backup
-
No need of internet connection to work
(only needed to synchronize occasionally)
Git has integrity
-
Everything is checksummed
-
References are SHA-1
24b9da6552252987aa493b52f8696cd6d3b00373
Git doesn't delete
-
Git generally only adds data
-
If you mess up, you can usually recover your stuff
-
Recovery can be tricky though
The three states
- Modified
- Staged
- Committed
Workflow
The git directory
- Located at .git/ (it's hidden)
-
Contains the entire history, i.e.,
a copy of all the versions of all the files ever tracked by git and all the past folder tree structures - When we checkout we copy a set of files from this directory in the working directory
The working directory
- The folder content we actually see in our file explorer
- A single checkout from a Git repository
The Staging Area
- Contained in a file
-
Tracks what will go into the next commit
AKA "the index"
File Status Lifecycle
The three states
- Untracked means that git is not managing the file in any way
- Committed means that the data is safely stored in your local database.
- Modified means that you have changed the file but have not committed it to your database yet.
- Staged means that you have marked a modified file in its current version to go into your next commit snapshot.
What of these facts about git are true?
- It's good in managing large binary files
- Every clone of the repository is a backup
- Requires internet connection to work
- Every operation is fast
What is the staging area (the index)?
-
The folder that contains the whole git history
-
A file that tracks what will go into the next commit
-
The way git refers to the current working directory
sanity check
List 3 advantages of using a VCS
LEARning goals
- Describe what a version control system is and list the main advantages of using it
- List the main advantages of git over other version control systems
- Understand the file status lifecycle
Now Git to work!
Resources
- "Pro Git" Book http://git-scm.com/book
- Git reference http://git-scm.com/docs
- Git great slides http://bit.ly/1bjTXJR
- Github git challenges http://try.github.com/
- Gitimmersion tutorial http://gitimmersion.com
- Git Flow http://bit.ly/197szRP
- Cheat sheet http://wbrp.li/14Dqrgh
- Use svn from git http://wbrp.li/XnpaUp
- Commands git vs svn http://wbrp.li/YCw4bb
CreditS
Git - Lesson 1
By Simone Gaiarin
Git - Lesson 1
VCS, git, file status life cycle
- 974