system A Source Code Management system: • Keeps track of changes to your code across versions • Lets you switch between different versions a.k.a Version Control Version Control: • The “Big Undo” • Support concurrent and iterative development • Simplify code sharing and multi-developer projects
system A Source Code Management system: • Keeps track of changes to your code across versions • Lets you switch between different versions a.k.a Version Control Version Control: • The “Big Undo” • Support concurrent and iterative development • Simplify code sharing and multi-developer projects
Linus Torvalds for the Kernel • Open-source (GPL v2) • Cross-platform: Linux, Windows, OS X, Solaris • Suitable for projects ranging from a few to tens of millions of lines of code. • Distributed • FAST!!!
between a client and a server • Each repository contains the entire code history • Available offline • Sync changes between any two repositories α β γ δ
using your distro's package manger. If your distro doesn't have Git in its software repositories, consider switching to a saner distro • Mac OS X: http://git-scm.com/download/mac • Windows: http://git-scm.com/download/win
On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # foo.txt nothing added to commit but untracked files present (use "git add" to track)
2nd line” >> foo.txt $ git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: foo.txt # no changes added to commit (use "git add" and/or "git commit -a")
is a random line...” >> foo.txt $ git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: foo.txt # no changes added to commit (use "git add" and/or "git commit -a")
snapshot of your source code at some point in time. • Each commit is identified by a 40 character string 44c17cdf64061ded390421143076abe9a9016a16 i.e. the SHA-1 hash • Most other systems store data as changes to a base version; Git treats data as a set of commits.
snapshot of your source code at some point in time. • Each commit is identified by a 40 character string 44c17cdf64061ded390421143076abe9a9016a16 i.e. the SHA-1 hash • Most other systems store data as changes to a base version; Git treats data as a set of commits.
snapshot of your source code at some point in time. • Each commit is identified by a 40 character string 44c17cdf64061ded390421143076abe9a9016a16 i.e. the SHA-1 hash • Most other systems store data as changes to a base version; Git treats data as a set of commits.
snapshot of your source code at some point in time. • Each commit is identified by a 40 character string 44c17cdf64061ded390421143076abe9a9016a16 i.e. the SHA-1 hash • Most other systems store data as changes to a base version; Git treats data as a set of commits. Git behaves like a mini filesystem!
Working Tree: Contents of your code directory • Staging Area: Stores what goes into next commit • Repository: Set of commits; HEAD-->Checked-out Working Tree
Working Tree: Contents of your code directory • Staging Area: Stores what goes into next commit • Repository: Set of commits; HEAD-->Checked-out Staging Area Working Tree
Working Tree: Contents of your code directory • Staging Area: Stores what goes into next commit • Repository: Set of commits; HEAD-->Checked-out Repository Staging Area Working Tree
Working Tree: Contents of your code directory • Staging Area: Stores what goes into next commit • Repository: Set of commits; HEAD-->Checked-out Repository Staging Area Working Tree
Note: checking out '36f461b160c278f1e86ffc6fab23f4a41f98824c'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new_branch_name HEAD is now at 36f461b... Initial Commit
On branch new-branch # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: foo.txt # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # feature.txt no changes added to commit (use "git add" and/or "git commit -a")