Ivor O’Connor

May 15, 2009

My git Tutorial For Ubuntu: PART 1

Filed under: Uncategorized — Tags: , , , , — ioconnor @ 1:20 am

This is the first installment of several. It addresses how to set it up. Does it really save everything. And must you issue commands from a particular directory…

  • Q0: How do I start using git?
    1. sudo aptitude install git
    2. git –version
      git version 1.6.0.4
    3. git config –global user.name “your name”
    4. git config –global user.email “you@something.fun”
    5. git config –global color.ui “auto”
    6. git config –list
    7. mkdir ~/gitmo
    8. cd ~/gitmo
    9. git init
    10. touch me
    11. git add -A
    12. git commit -m”h”
      Created initial commit f0e8798: h
      0 files changed, 0 insertions(+), 0 deletions(-)
      create mode 100644 me


      And now the files are stored away

    That’s basically all somebody needs to know if they are working by themselves without release versions. a “git help” on some command can fill in the rest.

  • Q1: Does git really save everything? Maybe you’ve watched the video of Linus’ at google where he stresses it records everything in your project exactly as it is. Here’s proof it does not!
    1. mkdir ghost
    2. git add -A
    3. git status
      # On branch master
      nothing to commit (working directory clean)
    4. git commit -m”Q1″
      # On branch master
      nothing to commit (working directory clean)

    Yep. An empty directory is as visible as a ghost is to most of us. You don’t get back what you put in to git. Linus can go on talking about how an empty directory is an error on your part, bad coding, or poopoo it as much as he’d like but the fact is his golden git can’t see an empty directory. (It’s interesting he does not think a file with nothing in it is an error also.)

  • Q2: Will git save away non-empty subdirectories and files at any depth?
    1. mkdir d1
    2. cd d1
    3. touch megently
    4. mkdir d2
    5. cd d2
    6. touch me
    7. mkdir d3
    8. cd d3
    9. touch medeeply
    10. git add -A
    11. git status
      # On branch master
      # Changes to be committed:
      # (use “git reset HEAD …” to unstage)
      #
      # new file: medeeply
      #
      # Untracked files:
      # (use “git add …” to include in what will be committed)
      #
      # ../me
      # ../../megently
    12. cd ../../..
    13. git add -A
    14. git status
      # On branch master
      # Changes to be committed:
      # (use “git reset HEAD …” to unstage)
      #
      # new file: d1/d2/d3/medeeply
      # new file: d1/d2/me
      # new file: d1/megently
      #
    15. git commit

    Yes and no is the answer. You must work with git from the same directory the git init was done from. Otherwise not everything will be saved. That’s a good thing. It allows for granularity.

This is the first part in a multi-part series. It’s enough to start with.

Part 2 is here.

Advertisements

3 Comments »

  1. […] first part of this git tutorial started here. Leave a […]

    Pingback by My GIT Tutorial For Ubuntu: Part 2 « Ivor O’Connor — August 11, 2009 @ 7:10 pm

  2. Is there a tutorial for people who don’t already know all about git? Where?

    Comment by Cameron — September 10, 2009 @ 9:33 pm

    • There is only one book out on git that I know of and I do own it. (I like books.) Checkout his website at http://www.travisswicegood.com/index.php/2008/03/23/pragmatic-version-control-using-git. The book works you through basic stuff. I found the first project walk through a very useful introduction. The rest of the book could have benefited with more examples. I’d like to have seen more of a cookbook approach with red flags. The #git irc channel is active. I always get answers within seconds from multiple people eager to help. I learn best with examples so I usually ask for an URL to a tutorial showing what I’m looking for in particular.

      Comment by ioconnor — September 10, 2009 @ 10:45 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: