Git On Windows Plain Introduction
Upcoming SlideShare
Loading in...5
×
 

Git On Windows Plain Introduction

on

  • 18,630 views

Plain Introduction to Git On Windows

Plain Introduction to Git On Windows
install msysgit, configure git, make your first repository and commit, look at objects and learn more

Statistics

Views

Total Views
18,630
Views on SlideShare
18,363
Embed Views
267

Actions

Likes
9
Downloads
157
Comments
1

8 Embeds 267

http://weijing329.blogspot.tw 69
http://www.slideshare.net 57
http://weijing329.blogspot.com 51
http://wiki.bcmoney-mobiletv.com 48
http://weijing329.wordpress.com 33
http://weijing329.blogspot.ca 5
http://weijing329.blogspot.hk 3
http://weijing329.blogspot.sg 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Git On Windows Plain Introduction Git On Windows Plain Introduction Presentation Transcript

    • Git On Windows Plain Introduction for testers; and you? marekj | testR.us helping testers adopt watir
    • 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.
    • 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
    • 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.
    • install msysgit
      • Double click exe file to start
        • install to default location or c:programsgit (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).
    • 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.
    • 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 &quot;~&quot; directory
        • &quot;~&quot; (tilda) a unix notiation that expands to home path
    • 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 =>
    • 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
    • ~/.bash_profile
      • When git bash starts it reads settings in your &quot;~/.bash_profile&quot; file if you have one set up to customize your bash session
      • learn more: google for &quot;.bash_profile&quot; or search github.com for dotfiles repositories and borrow settings from other people.
    • gitconfig and ~/.gitconfig
      • gitconfig: global settings
        • look at: Programs/Git/etc/gitconfig
          • notice the setting &quot;autocrlf = true&quot; (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
    • LF and CRLF line endings
      • Git knows you are on Windows.
        • &quot;autocrlf = true&quot; 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
    • Introduce yourself to git
      • execute commands in bash
        • git config --global user.name <name>
        • git config --global user.email <email>
        • (this gets written to your ~/.gitconfig file)
    • git going with git init
        • so you are in bash, yes?
        • and you are in &quot;testgit&quot; directory, yes?
        • ok, let's initialize a new repository with &quot;git init&quot;
        • what happened?
        • git created a .git
        • directory
        • take a look =>
    • 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 (&quot;testgit/.git/index&quot;)
          • this is where git keeps snapshot to be committed permanently to Repository
        • Repository (&quot;testgit/.git/objects/*&quot;)
          • This is the history of commits, trees, blobs etc..
    • 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
    • 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
    • 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)
    • git add . (or current dir)
      • a dot &quot;.&quot; in unix and windows means 'current directory' (fyi: the two dots &quot;..&quot; means parent directory)
      • execute
      • &quot;git add .&quot;
      • and check
      • status =>
    • what happened?
      • you just told git to scan current Working Directory and make a snapshot (photo) of how things look and put in 'Index&quot;
        • 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'
    • 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 d712f52
      • we'll look at
      • that
      • later =>
    • look at git log
      • Now that you made your first commit let's take a look at the log with &quot;git log -p&quot;
      • notice the strange commit number bd71252..blablablabla
      • and a unified diff format of your file changes
    • 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 More
      • http://book.git-scm.com/1_the_git_object_model.html
    • 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
    • example of 3 git objects
      • in our example
      • commit object
      • points to
      • Tree object
      • which points to
      • Blob object
      • (you don't need all 40 chars)
    • Learn More
      • Well. I think the next step is to read guides and books online.
      • start with the git community book
      • http://book.git-scm.com
    • 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 &quot; (%s)&quot;) $ e[0m '
      • Notice the git branch name in your prompt => (this one is Watir branch)
    • Thank you next we'll do github, ok? marekj | testr.us web browser automation with watir http://github.com/marekj/watirloo