Git On Windows Plain Introduction

Uploaded on

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

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Git On Windows Plain Introduction for testers; and you? marekj | helping testers adopt watir
  • 2. 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.
  • 3. 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
  • 4. Download msysgit
    • get msysgit exe file from here:
        • (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.
  • 5. 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).
  • 6. 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.
  • 7. 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
  • 8. 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 =>
  • 9. git bash here
    • and now your command window shows something like this. This is not git yet. this is bash prompt
    • learn more:
  • 10. ~/.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 for dotfiles repositories and borrow settings from other people.
  • 11. 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:
  • 12. 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:
  • 13. Introduce yourself to git
    • execute commands in bash
      • git config --global <name>
      • git config --global <email>
      • (this gets written to your ~/.gitconfig file)
  • 14. 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 =>
  • 15. 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..
  • 16. 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
  • 17. 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
  • 18. 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)
  • 19. 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 =>
  • 20. 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'
  • 21. 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 =>
  • 22. 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
  • 23. 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
  • 24. 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
  • 25. 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)
  • 26. Learn More
    • Well. I think the next step is to read guides and books online.
    • start with the git community book
  • 27. 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 ~/
    • 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)
  • 28. Thank you next we'll do github, ok? marekj | web browser automation with watir