Git Out!
The basics of using Git for source control management and deployment
(Subtitle: Powerpoint is for Suckers!)
Created by Todd E. Qualls / @teqknowledgy
What is Git, Anyway?
"Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency."
-- git-scm.com
(If you don't know Git from Shinola,
git-scm.com is a fantastic place to start.)
Unofficially
TFS : Winnebago
Git : Batmobile
-- TQ
Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).
Why the heck is Git called Git?
"I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'Git'"
-- Linus Torvalds
("git" is British slang for "pig headed" or roughly, an a**hole)
Basic Terms
- Repository (repo): An object database that contains your history and configuration info.
- Commit: The state of your project at a point in time containing pointers to other parent commits and referred to as an SHA1 hash.
- Working Copy: The current, uncommitted state of your repository.
- Staged Files: The files from your working copy that have been selected for a commit.
- Branch: A line of development (the default is called "master"). A branch is just a friendly label that points to commit with a specific ancestry.
- Remote: A non-local copy of the repository (typically called "origin" by convention, but can be called most anything) accessed via either SSH or HTTPS (more on that in a minute).
A basic git workflow
Though there are many GUI tools available, but we are focusing on the command line.
On Windows, the most common CLI for using Git is called git-bash.
View what files have changes and/or which are staged (optional)
$ git status
Specify which files you want to include in your "commit" (in this case, all new, changed, and deleted files)
$ git add --all
Commit your staged files from the current branch (master) to your local repository with a descriptive message
$ git commit -m 'This commit adds happy little trees all over teh internets.'
Retrieve the most recent changes that may have been pushed to the remote repository by others
$ git pull origin master
(Fix any merge conflicts that resulted from the pull from the remote known as "origin" using a tool like KDiff3)
Commit your changes to the branch (master) to the remote repository (origin)
$ git push origin master
Demo 1
- Create and checkout a new experimental branch
- Checkout oldiebutgoodie.js from the reallyoldbranch branch
- Integrate some of ye olde functionality into our current project
- Stage our changes
- Commit the changes
- Checkout the master branch again
- Merge the changes to the experimental branch into our master branch
function reallyUsefulEngine(coal, water, fire) {
var steam = coal + water + fire;
return steam;
}
Demo 2
- Push local updates to Github repository
- Push and publish to production site on Azure
Demo 3
- Create new Azure site with deployment trigger for Github repository
- Push local updates to Github repository
- Sit back and relax while our project automatically deploys to Azure