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
    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.


Create a free website or blog at WordPress.com.