git practices

Peter Hutterer peter.hutterer at who-t.net
Tue Oct 13 19:11:56 PDT 2009


Note that while I'm writing this email there's a discussion on IRC about
this anyway, so I don't know what the final verdict will be on that.

On Tue, Oct 13, 2009 at 05:56:37PM -0700, Jeremy Huddleston wrote:
> Thanks.  That answers some questions, but I'm still left with others.
>
> The following commands give me puzzlement.  Please correct my  
> misunderstandings.  This is assuming the first case of push (my personal 
> tree has been merged into origin/master)
>
> Assuming:
> origin/master has the following commits:  A B C D E F G H 1 2 3 4
> bond007/master has the following commits: A B C D 1 2 3 4
> local branch matches bond007/master
>
> (ie, bond007/master has commits not in origin, and origin has some not  
> in bond007)
>
> $> git pull --rebase
>
> This fetches from the remote tree that the current branch is tracking... 
> most likely origin/master
>
> origin/master has the following commits:  A B C D E F G H 1 2 3 4
> bond007/master has the following commits: A B C D 1 2 3 4
> local branch has the following commits  : A B C D E F G H 1 2 3 4

yes, but no.  git isn't linear on a single line, you're missing the merge
here. so origin/master is more like
A B C D E F G H-M
       \1 2 3 4/

One example - Alan's recent pull:
$> git log --graph --pretty=oneline 24e640e1fa6cfb391..44efcdde501d54ca9
* 44efcdde501d54ca9c3e33ab5b1f699956fc3f9f Fix overlay detection when matching Xv adaptors across screens.
*   68304215e25876ee639015969b4f07e1c9c515e0 Merge remote branch 'alanc/master'
|\  
| * 315aaef55750a863c08a16ad9120ffb76f9b48e0 Use $(AM_V_GEN) to silence more commands when AM_SILENT_RULES is active
| * 2e294380b64b6362173d0590c4292f290e50af50 Migrate to xorg macros 1.3 & XORG_DEFAULT_OPTIONS
| * 4b0911565d18b1aefca564315d0f1b9b4a17aa65 Add platform tests for Dtrace linker magic
| * 8c51b886400c5962b31ff565771be1b01a3ca8fb configure: quote argument to m4_pattern_forbid
| * 6ee61578ddb9f880ef12bbe9c3671d7dd53f2809 Remove shave now that automake-1.11 has AM_SILENT_RULES
| * d5d960f57834f16164457dab2e80290717dbf2cd render: Fix clip region translation in miClipPictureSrc().
| * d2118c8ca94fc7bcb8e0de547e63cf022f53a8a9 xfree86: remove log-spamming DebugF
| * bf116057c7efd43c247c93f2f5d733a5db857cc9 Require libXtst >= 1.0.99.2 and libdmx >= 1.0.99.1
| * 1a2dde3335864abfbbc133dbc709f564272dd540 Set XQUARTZ to no on non-Darwin OS'es
* 6676f49e34f8db7ef5767a6dbf6c2a4d2087f79c configure: quote argument to m4_pattern_forbid
* a0363bf7b135d816e73849c91fa53d98fd6072d1 Remove shave now that automake-1.11 has AM_SILENT_RULES
* cbc886a3513079c084fb7ce47b87c3e5bba19f3f render: Fix clip region translation in miClipPictureSrc().
* bd7430a32e63df8cd60352764744076448ee623f xfree86: remove log-spamming DebugF
* c629e0fc50dfaffaa40a56709da7f035c289fed2 Require libXtst >= 1.0.99.2 and libdmx >= 1.0.99.1

Rebasing from 315aaef (last on alan's branch) to master is fast-forward.
Anything you apply on top of that can then be rebased again.

The rest of your comments were based on the linear history assumption, so
I'll skip them :)

> As for the second case (it has not been pulled into master):
>
> Assuming:
> origin/master has the following commits:  A B C D E F G H
> bond007/master has the following commits: A B C D 1 2 3 4
> local branch matches bond007/master
>
> $> git pull origin # if you need to sync with master
>
> origin/master has the following commits:  A B C D E F G H
> bond007/master has the following commits: A B C D 1 2 3 4
> local branch has the following commits:   A B C D 1 2 3 4 EFGH
>
> I thought this was the huge "badness" which shows a bunch of "branch  
> ____ merged with branch ____" messages that get super messy because pull 
> is essentially a fetch/merge.

You do get them, yes. How much of a problem they're going to be in the
futurue I don't know. They can be nasty when bisecting and confusing in the
history.

> $> git am -s <patches from list>
> # test
>
> commit patches locally:
> origin/master has the following commits:  A B C D E F G H
> bond007/master has the following commits: A B C D 1 2 3 4
> local branch has the following commits  : A B C D 1 2 3 4 EFGH 5 6 7 8
>
> $> git rebase -i origin/master
>
> reorder, cleanup, etc all changes since origin/master ... but we aren't 
> actually tied to origin/master any more... this is what confuses me... 
> the "pull" resulted in merging all changes in origin/master since our 
> common ancestor into one commit, so we don't actually have origin/master 
> in our history.

I think this should be the merge commit instead of origin/master. Need to
test this again and fix the documentation. Note that due to the merge
commit, both bond007/master and origin/master are in the history. 
Have a look at the master branch with tig, by default it shows all known
refs in the history. e.g. in the current origin/master tree I can see
daniels/master, alanc/master and mattst88/master (and of course my own one).

Cheers,
  Peter


More information about the xorg-devel mailing list