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?
- sudo aptitude install git
- git –version
git version 1.6.0.4
- git config –global user.name “your name”
- git config –global user.email “you@something.fun”
- git config –global color.ui “auto”
- git config –list
- mkdir ~/gitmo
- cd ~/gitmo
- git init
- touch me
- git add -A
- 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!
- mkdir ghost
- git add -A
- git status
# On branch master
nothing to commit (working directory clean) - 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?
- mkdir d1
- cd d1
- touch megently
- mkdir d2
- cd d2
- touch me
- mkdir d3
- cd d3
- touch medeeply
- git add -A
- 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 - cd ../../..
- git add -A
- 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
# - 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.
[...] 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
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