Sunday, June 22, 2008

Interacting with GIT

Git interactive rocks!

It's a quick and easy way to stage several files [for a subsequent commit], regardless of location and name, without an IDE or ninja master scripting skills . . .example follows: [my typing in bold]

machine1$ git add -i
staged unstaged path
1: unchanged +7/-2 Classes/AllViewController.m
2: unchanged +2/-0 Classes/AppDelegate.h

*** Commands ***
1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked
5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp
What now> 4

1: Classes/FilteredByGroupViewController.h
2: Classes/FilteredByGroupViewController.m
3: Classes/GroupsViewController.h
4: Classes/GroupsViewController.m
Add untracked>> 1-4
* 1: Classes/FilteredByGroupViewController.h
* 2: Classes/FilteredByGroupViewController.m
* 3: Classes/GroupsViewController.h
* 4: Classes/GroupsViewController.m
Add untracked>> [enter]
added 4 paths

*** Commands ***
1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked
5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elp
What now> q
Bye.

machine1$


update (July 1): just for comparison, a co-worker sent me one of those wonderful scripting commands for subversion to add all unknown files:

svn stat -u | awk '/^[?]/ { print $NF }' | xargs svn add


Monday, June 16, 2008

Time to GIT you a quick update

I've either been living on an island, or I'm guilty of being a slowly boiled frog depending on how you look at it.  

Let's compare the default output for 'svn up' vs. 'git pull' shall we?  My annotations are in bold...

In this corner: 'svn up' . . .

$ svn up

U Classes/ClassA.m                <-- _awesome_ single letter indicator for

U Classes/AppDelegate.m           <--   what happened to the file during the update

U Classes/DynamicSheetDelegate.m       

U Classes/AlertDelegate.m                

U Classes/SalesTransaction.m             

U App.xcodeproj/user.pbxuser             

Updated to revision 1028.        <-- _short_ summary

$


and the challenger: 'git pull' . . . 

$ git pull                                

remote: Counting objects: 58, done.               <- Keeps you apprised of comm.

remote: Compressing objects: 100% (48/48), done.  <-  rather than pauses w/o info

remote: Total 48 (delta 37), reused 0 (delta 0)

Unpacking objects: 100% (48/48), done.

From git://machineB/projectA

   f355111..99258fb  master     -> origin/master    <- SHA-1's of from and to 

From git://machineB/projectA                        <-  versions on remote repo 

* [new tag]         aftermemfixes -> aftermemfixes  <- New tags on remote repo 

Updating f355111..99258fb                           <- SHA-1's of current to new ver

Fast forward                                        <-  on local repo + current op.

 Classes/ClassA.m                       |   25 +-   

 Classes/AppDelegate.m                  |   11 +-   <- Counters and visual (ascii :)

 Classes/DynamicSheetDelegate.m         |    2 +    <-  indicators show amount of

 Classes/AlertDelegate.m                |    2 +    <-  change on per-file basis

 Classes/SalesTransaction.m             |    5 +-   

 App.xcodeproj/user.pbxuser             | 2510 ++++++++++++++++++--------------

 7 files changed, 1604 insertions(+), 1176 deletions(-)  <- Summary totals 

$




Sunday, June 15, 2008

WWDC 2008 wrap-up

I just got back from WWDC 2008 . . .  Unfortunately there is a confidentiality agreement that prevents me from posting any technical details here, but if you hop around the rumors/news sites, you can find most of the juicy details.

In general, is was a very well produced conference.   For me, the best thing about it was the chance to talk one-on-one with some of the engineers behind key technologies on the platform.  The venue and location were great and I definitely got the impression that Apple values their development community tremendously.  If the conference was any indication, there will be some very cool and innovative Apps coming out on the iPhone.





Does it GIT any better than this?

Cool GIT feature of the moment:   Content based tracking of files.

I renamed a file in a project, and then did a 'git rm', and 'git add' to update the index and subsequently committed and pushed the changes.  Then, on the origin repo, I executed a 'git status' to see what changes were pending.  GIT displayed:

# renamed:    AllViewController.h -> RootViewController.h

# renamed:    AllViewController.m -> RootViewController.m


Huh?   It recognized that the content was renamed even though I had only communicated a 'delete' and 'add' operation for the file.   Apparently this is because GIT does sha-1 on all content -- allowing it to know when you move content around (even if you don't tell it).  Nice!



Saturday, June 14, 2008

The Pragmatics of Innovation




This guy is one hell of a speaker and he has a really great (pragmatic) perspective on innovation.   The idea that people sometimes tend to look back at innovations without considering any hard facts is something of an understatement.  Scott explains that true innovation comes from rigorous habits, not doing what you're told sometimes, and not letting past failures stop you.    It's also interesting how people sometimes think innovations come entirely from 'magic moments'/epiphanies.   Best example Scott uses:  How they teach you in school that Newton came up with the idea of gravity when an apple fell on his head.   HA!  Listen to Scott's talk to hear the real story.  Fascinating stuff.


Tuesday, June 10, 2008

It's GIT'ing better all the time.

Goals:
  • I have some source code that I need to share between a desktop and laptop sporadically.
  • When I'm working on the code on the laptop (potentially disconnected from any network for several days), I want all the same scm style capabilities (tagging, branching, roll-backs) that I get when I'm working on the desktop.
  • I don't want the overhead of maintaining a server securely or paying for a hosted solution.
  • I'll only ever be actively developing on either the laptop or desktop at any given time, so merges are no concern [for now].
After watching the ever opinionated Linus, a few git casts, and reading Wincent's summary, I was gung-ho convinced GIT could do the job.

GIT Recipe #1. One-way pushes between two trusted peers.


Given:
Base dir

|-> Myproject dir

Step 1. Create a GIT repo and index on machine #1 for your project.
machine1$ cd /myproject
machine1$ git init
machine1$ git add .
machine1$ git commit

Step 2. Start the git server component on Machine #1. Warning this allows fully anonymous unauthenticated access, so only do this in a secured LAN environment -- and personally, I would only do it for short sporadic bursts of time even in that environment. For a more secure option (i.e. - apache/ssh/etc), see the git docs (it's a bit more work).
machine1$ git-daemon --verbose --export-all --enable=receive-pack --base-path=/parentof/myproject/dir

Step 3, clone the repo to machine 2.

machine2$ git clone git://machine1/myproject


To do work on machine 1, and send the updates to machine 2

On Machine 1 (origin repo), remove a file and commit the change.
machine1$ vi README.txt
machine1$ git add README.txt machine1
machine1$ git commit


On Machine 2, pull those changes across

machine2$ git pull

To do work on machine 2, and send the updates to machine 1

Make some change . . .
machine2$ vi README.txt
machine2$ git add README.txt
machine2$ git commit

Push those changes over to the origin repo

machine2$ git push

Then, on Machine A [be careful not to have any local changes], to get those changes into your working copy:
machine2$ git checkout -f


Bottom-line: The big benefit here is that I can commit, tag and branch at will on either machine without them being connected, and then sync them up when there is connectivity. There are git workflows which allow for that capability with larger groups, but I personally only need this one workflow (working while disconnected) to function at the moment.

Some of the better GIT Resources I've found:
  1. http://rails.wincent.com/wiki/Git_advantages
  2. http://www.youtube.com/watch?v=4XpnKHJAok8
  3. http://www.sourcemage.org/Git_Guide
  4. http://www.gitcasts.com
  5. http://www.rockstarprogrammer.org/post/2008/apr/06/differences-between-mercurial-and-git/
  6. http://cheat.errtheblog.com/s/git
  7. http://cheat.errtheblog.com/s/git_usage/
  8. http://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png
  9. http://code.google.com/p/git-osx-installer/
  10. http://www-cs-students.stanford.edu/~blynn/gitmagic/index.html
  11. http://google-opensource.blogspot.com/2008/05/develop-with-git-on-google-code-project.html
  12. http://osteele.com/archives/2008/05/my-git-workflow
  13. http://ktown.kde.org/~zrusin/git/git-cheat-sheet-medium.png
  14. http://www.dekorte.com/blog/blog.cgi?do=item&id=2539

Saturday, June 07, 2008

Eric Schmidt - What can others copy from Google, how does his style compare to other CEO's


Great video with CEO Eric Schmidt on a variety of mgmt topics, challenges he faces at google, and how he tries to facilitate the focusing of the energies of passionate engineers and founders.  He alludes to what he thinks would be hard for others to copy, and what wouldn't.

One thing in particular that Eric mentions is along the lines of:  When you have smart people, encourage debate on anything and everything, BUT you MUST set a dead-line and make decisions in order to ensure your organization doesn't devolve into a purely academic environment.   He also talks about keeping people involved, how to challenge people and evaluate innovation ideas.  On challenging and evaluating innovative ideas, he seems to embrace a model similiar to Bill Gate's -- rigorously challenging down to the details and requiring hard facts.  Good stuff.