July 14, 2012
Instructor: Brian Layman (@BrianLayman)
Slides: http://www.slideshare.net/brianlayman/how-to-gitwiththeprogrambrianlaymanwordcampcolumbus2012
Allows you to track and undo changes to you code while making it easier for multiple developers to work on the same code. Through branching, you can also work on several different versions of your code at once.
Popular systems
- Git (FTW!)
- CVS (Concurrent Versions System)
- SVN (SubVersioN)
- Mercurial
CVS and SVN are not predecessors to Git; they work in different ways (centralized version control v. distributed version control)
Advantages to distributed version control
- Your own copy of the repo
- Can commit to other servers
- Fast, offline, redundant
SVN is simply not as advanced and "fakes" some of the standard VCS features
Repository - Your project and its history
Branch - A separate and unique version of your code
Tag - Your branch/repo at a specific point in time
Clone (Checkout in SVN) - Make your repo local
Add - Start tracking another file/tree
Commit (Git Only) - Add your changes to your local repo
Push (Commit in SVN) - Add your changes to a server
Pull (Update in SVN) - Bring in changes from a server
Revert (Git only) - Undo a local commit
Checkout (Revert in SVN) - Get a specific server revision
Snapshots - Local commits
Remote - Any other server with the current repository
Diff - Compare two file versions
Conflict - When a server has a different change to a line that is changed on your local computer
Merge - Bring the changes from one branch into your local branch (in SVN this is called PAIN)
Status - Shows the current state of the files
Log - All of the recent commits
- Create a repository
- Add a readme file to the repo
- Commit the change (with a proper commit message, naturally)
- Connect the repo to a remote server
- Push the change to the remote
- Make changes
- Commit (repeat)
- Pull updates to the server
- Push
Windows: SmartGit, TortoiseGit
Mac: Github for Mac, SourceTree
More: http://bit.ly/GitUIs
Of course, you can always be awesome and just use the CLI (or Git Bash on Windows)
git fetch
- Shows what will come down with a pull
git reset HEAD README
- Unstage changes to README
git checkout -- README
- Revert file README
git revert
- Commit changes to undo last commits
git commit --amend
- Modify the last commit
git blame
- Determine who made a specific change
See slides for more