[pony-build] Using git to look at differences

C. Titus Brown ctb at msu.edu
Sun Jan 24 14:26:48 PST 2010


Hi all,

I thought I'd send out some information on how to use git to look
at changes that someone else made.  There are probably many ways
to do this but I am most familiar with this -- let me know if you
know git & do something else!

Let's suppose that Max (github user 'mlaite') has a branch 'mkdir'
in his pony-build repository, and you want to look at what changes
he made just on that branch.  (You should be able to run everything
on your own machine.)

First, set up his repo in your 'remote' list so that you have easy
access to it:

% git remote add mlaite git://github.com/mlaite/pony-build.git

Now fetch his 'mkdir' branch into your repository:

% git fetch mlaite mkdir:max_mkdir

This downloads his branch 'mkdir' and makes an exact copy in your local
repository under the branch 'max_mkdir'.

Check out your new branch:

% git checkout max_mkdir

and look at the log messages for the last few revisions:

% git log

You should see something like what is in the attached diff-1.txt.  What you'll
notice is that Max made four commits, all on Saturday.  You probably don't care
about the differences between his various commits -- you're just interested in
what he did since my last commit last Sunday.

You can get the difference between any two commits with 'git diff name1 name2'
where 'name1' and 'name2' are strings that uniquely identify the commit IDs you
want to diff; in this case, you can use 6a7507a9e (for my last commit) and
4f7d6741 (for Max's most recent commit).

So to see the differences, do:

% git diff 6a7507a9e 4f7d6741

Note, you can actually just use 

% git diff 6a7507a9e

because if you don't specify a second commit it will just assume that you
want the diff between the given commit and the copy currently in your
directory.

I can talk a bit about how to read diffs if you like, but it should be
reasonably obvious :)

** IMPORTANT: After all this is over, be sure to switch off of this branch --
if you haven't been using branches, do 'git checkout master' to get back to
your own master branch.

cheers,
--titus
-- 
C. Titus Brown, ctb at msu.edu
-------------- next part --------------
commit 4f7d6741282f9bf90d4a22a1c7b5157b0a2f4c70
Author: MLaite <mlaite at gmail.com>
Date:   Sat Jan 23 21:00:24 2010 -0400

    silly cwd mistake corrected, should be all good now

commit bf3bf8b653884a5bd6835353307be7556a1b4d7c
Author: MLaite <mlaite at gmail.com>
Date:   Sat Jan 23 19:53:29 2010 -0400

    add some comments

commit f44cbc75f57cd22c85d3be5bd06187d423a6a7b4
Author: MLaite <mlaite at gmail.com>
Date:   Sat Jan 23 19:41:34 2010 -0400

    typo

commit b85106cceecd75f83860a152e07de53163699ba3
Author: MLaite <mlaite at gmail.com>
Date:   Sat Jan 23 17:11:37 2010 -0400

    initial git cache creation

commit 6a7507a9e96dd884086c250a22976d393397ac86
Author: C. Titus Brown <titus at idyll.org>
Date:   Sun Jan 17 15:58:16 2010 -0500

    beginning Mercurial code



More information about the pony-build mailing list