Skip to main content.

Git flythrough

Version used in this document (at least)

[dzu@pollux u-boot]$ git --version
git version 1.5.3.1

Technical introduction

Underlying concepts

Programmatically git is a collection of small user space programs exposing all the "bolts and nuts" in the typical unix fashion (called "plumbing", e.g. git-cat-file).

[Sidenote: this allowed for very rapid prototyping in a script language and subsequently optimizing critical parts in C]

Git also includes "porcelain" commands (e.g. git-show") to work with the core plumbing programs. Other porcelains are possible of course.

Basic interaction with the object database

Working examples

Cf. http://www.kernel.org/pub/software/scm/git/docs/

Check out master repository

Elegant ways top check out a repository:

Normal clone

[dzu@pollux dzu]$ git clone /home/git/u-boot
Initialized empty Git repository in /tmp/dzu/u-boot/.git/
remote: Generating pack...
remote: Done counting 44005 objects.
remote: Deltifying 44005 objects...
remote:  100% (44005/44005) done
Indexing 44005 objects...
remote: Total 44005 (delta 35236), reused 42526 (delta 33832)
 100% (44005/44005) done
Resolving 35236 deltas...
 100% (35236/35236) done

[dzu@pollux dzu]$ du -hs u-boot/
74M  u-boot/

Using alternates

[dzu@pollux dzu]$ rm -rf u-boot/
[dzu@pollux dzu]$ git clone -s /home/git/u-boot
Initialized empty Git repository in /tmp/dzu/u-boot/.git/

[dzu@pollux dzu]$ du -hs u-boot.
53M u-boot/
[dzu@pollux dzu]$ 

Using remotes in an U-Boot example

[dzu@pollux u-boot]$ git clone /home/git/u-boot
Initialized empty Git repository in /tmp/dzu/u-boot/u-boot/.git/
remote: Generating pack...
remote: Done counting 44005 objects.
remote: Deltifying 44005 objects...
remote:  100% (44005/44005) done
Indexing 44005 objects...
remote: Total 44005 (delta 35236), reused 42526 (delta 33832)
 100% (44005/44005) done
Resolving 35236 deltas...
 100% (35236/35236) done

[dzu@pollux u-boot]$ cd u-boot
[dzu@pollux u-boot]$ git-remote add -f 4xx git://www.denx.de/git/u-boot-ppc4xx
remote: Generating pack...
remote: Done counting 0 objects.
remote: Total 0 (delta 0), reused 0 (delta 0)
Unpacking 0 objects...
...
[dzu@pollux u-boot]$ git-remote add -f testing git://www.denx.de/git/u-boot-testing
...
[dzu@pollux u-boot]$ 

Powerful tools

Introducing yourself to git

Looking for whats there

"Seeking in time"

  1. Only for viewing/compiling: git-checkout testing/master
  2. To work, crate a (temp.) branch: git-checkout -b work U-Boot-1_2_0

Inspecting state

Resetting to "unfolded tree"

"Addressing" versions and insepcting "traces"

Comparing trees and files

Show history of files

Commiting work

  1. git-add
  2. git-commit -s

or

Generating patches

Custodian:

git-checkout -b work U-Boot_1_2_0
   [edit, change, commit]
git-format-patch -n `git-merge-base HEAD origin/master`
git-send-email [--thread] 00*

Maintainer:

[Collect patches in standard mailbox file mbox]
git-am mbox

Rebasing branches (and thus patches)

Pushing and pulling

Update master branch (fetching + merging):

  1. git-checkout master
  2. git-pull

Sync up to all remotes also (no merging done):

Push changes through ssh:

Merging branches

  1. git-checkout origin/master
  2. git-merge testing/master

Removing branches and cleaning up

  1. git-branch -d work
  2. git-gc

Goodies

Find tags:

Generate pull requests automatically

git-bisect

Checkout "bad" version.

  1. git-bisect start
  2. git-bad
  3. git-good ...

Now a position "in the middle" is checked out for testing. Tell the system by

git-bisect good or git-bisect bad

Git tells you when the culprit was isolated.

good - f5577aae4aa9f245c4c67308fe0f7b3cecf61c93
  (needs "fixup", e.g. touch examples/hello_world.{srec,bin})
bad - 8318fbf8cc30418b621ea9f39b84b4c1a08f003a

[dzu@pollux u-boot]$ git-bisect reset
[dzu@pollux u-boot]$ git-bisect start
[dzu@pollux u-boot]$ git-bisect good
f5577aae4aa9f245c4c67308fe0f7b3cecf61c93
[dzu@pollux u-boot]$ git-bisect bad
8318fbf8cc30418b621ea9f39b84b4c1a08f003a
Bisecting: 35 revisions left to test after this
[854bc8da75709f13dab4cfa6e9094c0cb49b5c5a] Add support for AMCC
Rainier PPX440GRx eval board
[dzu@pollux u-boot]$

... make ... bad 
... make ... bad
... make ... bad
... make ... good
... make ... good

[dzu@pollux u-boot]$ git-bisect bad
Bisecting: 0 revisions left to test after this
[d7c2a02dea550e8701d1151010a823df48ad5c98] Added simple_strtoul(),
getenv() and setenv() to the exported functions.
[dzu@pollux u-boot]$

Further reading: