git on windows plain introduction
DESCRIPTION
Plain Introduction to Git On Windowsinstall msysgit, configure git, make your first repository and commit, look at objects and learn moreTRANSCRIPT
Git On Windows Plain Introduction for
testers; and you?
marekj | testR.ushelping testers adopt watir
marekj | testr.us
why this plain introduction?
• You are a software tester– you work mainly on windows– you have heard about git– you want to experiment– you need some tools from github that you can
use on your job (like watircraft or watirloo)– or you are curious how to get you mind around
this git thing everyone is talking about...
ok, let's get started.
marekj | testr.us
Roadmap
• In this presentation we will:– install msysgit (the git for windows)– tell git who you are– tell git you are on windows– init first git repository– look at 3 git spaces and 4 git objects– and send you to git community book
http://book.git-scm.com/index.html
marekj | testr.us
Download msysgit
• get msysgit exe file from here: http://code.google.com/p/msysgit/(probably Git-1.6.1-preview20081227.exe)
• No, we don't want the cygwin version, we want msysgit for sure.
• Please now take the time to appreciate the guys who wrote and maintain git and msysgit. I am sure they will appreciate it.
marekj | testr.us
install msysgit
• Double click exe file to start– install to default location or c:\programs\git
(my preferred place)– select checkboxes for 'git bash here' and 'git
gui here' windows explorer integration (yes, you want it).
– select radio 'git bash only' (don't worry about other options for now).
– select 'Use OpenSSH'. (built into git).
marekj | testr.us
Folder or Directory
• Folder is what Windows calls directory. In Unix there is no 'folder' concept. There are only files. In Unix everything is a file, even a directory is a file that contains other files.
• This important distinction will be used in git so make a note of it.
marekj | testr.us
About home directory
(skip this if you understand Unix and "~")– on windows your home folder is known as
"%USERPROFILE%" that system expands to proper path visible to you• c:\Documents and Settings\<name> on Win XP or
c:\Users\<name> on Vista
• git refers to this as "~" directory– "~" (tilda) a unix notiation that expands to
home path
marekj | testr.us
Make new folder and open git bash here
• In Windows Explorer open your home folder and make a new folder 'testgit'
right click on testgit and click 'git bash here'to open git =>
marekj | testr.us
git bash here
and now your command window shows something like this. This is not git yet. this is bash prompt
learn more: http://www.gnu.org/software/bash/manual/bashref.html
marekj | testr.us
~/.bash_profile
• When git bash starts it reads settings in your "~/.bash_profile" file if you have one set up to customize your bash session
learn more: google for ".bash_profile" or search github.com for dotfiles repositories and borrow settings from other people.
marekj | testr.us
gitconfig and ~/.gitconfig
• gitconfig: global settings– look at: Programs/Git/etc/gitconfig
• notice the setting "autocrlf = true" (later on this)• examine other files: motd and git-completion.bash.
we'll talk about that too later
• ~/.gitconfig: user settings file– tell git about yourself and your machine first
and your preferences to create this file.
Learn more:http://www.kernel.org/pub/software/scm/git/docs/git-config.html
marekj | testr.us
LF and CRLF line endings
• Git knows you are on Windows. – "autocrlf = true" in git/etc/gitconfig
• CRLF is for Windows and LF is for unix.– to keep cross platform development going
smooth keep CRLF for windows and LF for unix
– with autocrlf = true git converts your windows CRLF into LF internally
• learn more:http://github.com/guides/dealing-with-newlines-in-git
marekj | testr.us
Introduce yourself to git
• execute commands in bashgit config --global user.name <name>git config --global user.email <email>(this gets written to your ~/.gitconfig file)
marekj | testr.us
git going with git init
so you are in bash, yes?and you are in "testgit" directory, yes?ok, let's initialize a new repository with "git init"
what happened?git created a .gitdirectory take a look =>
marekj | testr.us
git and 3 conceptual spaces
• Git deals with 3 spaces. Each space is a self contained area of concern to git and to you. – Working Directory (our 'testgit' folder)
• this is where you keep your current files visible in directory or folder.
– Index or Stage ("testgit/.git/index")• this is where git keeps snapshot to be committed
permanently to Repository
– Repository ("testgit/.git/objects/*")• This is the history of commits, trees, blobs etc..
marekj | testr.us
git going with a new file
• Create ~/testgit/README.txt file– open the file and type 'hello git' and save it.
• ask git about status
marekj | testr.us
working directory changes
• git status scans your 'working directory' (1st area of concern to you) and reports to you what changed from a last known snapshot (either in Index or Repository)
• in this case we have a brand new file README.txt but git will not track it unless we tell it explicitly to do so with 'git add' command
marekj | testr.us
ask git to track changes
• when you tell git to 'add' file to be tracked you ask it to add it to its 'index' or 'stage' area (the second area of concern for you)– imagine you put the file on a stage in a
spotlight so that every one of its moves is tracked by git. (a bit of Hollywood metaphor here might help)
marekj | testr.us
git add . (or current dir)
• a dot "." in unix and windows means 'current directory' (fyi: the two dots ".." means parent directory)
execute"git add ."and checkstatus =>
marekj | testr.us
what happened?
• you just told git to scan current Working Directory and make a snapshot (photo) of how things look and put in 'Index"
– git stores the snapshot in the 'stage' or 'index' area (yes, that second area)
– if you were to modify README.txt at this time git will not have those changes in its index or stage. you would have to make a new 'photo'
marekj | testr.us
git commit -m 'message'
• record the 'stage' area permanently with git commit -m 'and message'
• it goes to 3rd area of concern (Repository)notice git tells you it created d712f52we'll look at thatlater =>
marekj | testr.us
look at git log
• Now that you made your first commit let's take a look at the log with "git log -p"
• notice the strange commit number bd71252..blablablabla • and a unified diff
format of your file changes
marekj | testr.us
git hash key known as SHA
• What is this 'SHA' thing?– the commit number is a 40 characters long
Secure Hash Algorithm 'object name' or SHA for short.
Learn Morehttp://book.git-scm.com/1_the_git_object_model.html
marekj | testr.us
git objects
• There are 3 objects we want care about at this time. (Objects in Repository)– COMMIT object (point in time to tree)– TREE object (point to dir and files)– BLOB object (file contents)– 4th object TAG we'll deal with later
• Every object is identified with SHA, a 40 char long key
marekj | testr.us
example of 3 git objects
in our examplecommit object points toTree object which points to Blob object
(you don't need all 40 chars)
marekj | testr.us
Learn More
Well. I think the next step is to read guides and books online.
start with the git community bookhttp://book.git-scm.com
marekj | testr.us
Extra. Configure Git Prompt
• copy programs/git/etc/git-completion.bash file to ~/.git-completion.bash file
• in file ~/.bashrc enter the following line source ~/.git-completion.sh
• in file ~/.bash_profile set this line to make your prompt: PS1='\e[32mpwd:\e[31;1m \W$(__git_ps1 " (%s)")\n$ \e[0m'
Notice the git branch name in your prompt =>(this one is Watir branch)
Thank younext we'll do github, ok?
marekj | testr.usweb browser automation with watirhttp://github.com/marekj/watirloo