Ivor O’Connor

August 11, 2009

My GIT Tutorial For Ubuntu: PART 2

Filed under: git — Tags: , , , , — ioconnor @ 6:36 pm

How do you push your changes to a new remote repository if you created the local repository with “git init”? Most developers probably start their projects using git on their local hard disk. When it comes time to making a remote repository for other people to pull from do the following:

Make a bare bone git repository on the server and then push to it from the head of your local repository:

ssh your-user@www.your-server.com
mkdir -p ~/some-path/…/…/your-repo.git
cd ~/some-path/…/…/your-repo.git
git –bare init
exit

cd your-local-git-repository
git remote add origin your-user@www.your-server.com:some-path/…/…/your-repo.git
git push origin master

Notice the syntax of the “remote add”. There is no “ssh://” as shown in some tutorials. And it’s important to avoid hard coding the path on the remote server by using the colon. If you get a
fatal: ‘your-repo.git’ does not appear to be a git repository
error when doing the push you can remove the origin with the command “git remote rm orgin” and continue trying the add until you get it right.

Notes:

  1. You probably need to set up your ssh keys first as described in a past post here.
  2. The first part of this git tutorial started here.
Advertisements

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.

May 11, 2009

Backups Via GIT: gibak

Filed under: howto, Linux — Tags: , , , , , , , — ioconnor @ 6:01 pm

What’s the best way to move data between two machines? As in migrating off this laptop and on to another laptop? Rsync with tar and rdiff-backup come immediately to mind. Why not with “git” instead? Supposedly git is much faster than anything and compacts stuff better too. Because of it’s strange algorithms you don’t have to worry about date discrepancies between machines either. It was written by Linus to be better than sliced bread. Here Linus is giving a presentation at Google on “git”. So every machine could contain exactly the same information across my networks. And since it is a distributed version control system, DVCS, what happens in Las Vegas doesn’t stay in Las Vegas. You’d also have the various versions of the data too.

Trying not to reinvent the wheel a quick google was done. Lucky thought on my part because somebody else has already made an application for this purpose called “gibak“. Here’s what the author says:

* it is more space-efficient than most incremental backup schemes, since it does file compression and both textual *and* binary deltas (in particular, it’s better than solutions relying on hardlinks or incremental backups à la tar/cpio)
* its transport mechanism is more efficient than rsync’s
* it is fast: recoving your data is *faster* than cp -a
* you keep the full revision history
* powerful toolset with a rich vocabulary

So what’s the catch? I don’t know. I’ll be playing with it today and update this blog with my results…

I played with it for quite some time but for some reason it would archive over 8GBs, which is all the space I currently have left on this laptop, and die. As a result I’m looking at using a drive on the network before I can resume this. (And unfortunately the documentation for doing this is lacking and the wee little bit that does exist is so badly incorrect it makes me think poorly on the testing that never gets done on Ubuntu.)

Create a free website or blog at WordPress.com.