git practices

Jeremy Huddleston jeremyhu at apple.com
Tue Oct 13 17:56:37 PDT 2009


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

$> git am -s <patches from list>
# test

commit patches locally:
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 5 6  
7 8

$> git rebase -i origin/master # if you need to reshuffle something

reorder, merge, etc all changes since 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 58 7 6

$> git push bond007 master

Push the current branch to bond007/master ... This seems wrong to me.   
The current branch is no longer a fast-forward of bond007/master.

We'd need to force it via (IIRC):
$> git push bond007 +master

but then that would rewrite history (which is bad) ... so... ?

--

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.

$> 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.

Thanks for clearing this up,
Jeremy


On Oct 13, 2009, at 16:45, Peter Hutterer wrote:

> On Tue, Oct 13, 2009 at 04:01:19PM -0700, Jeremy Huddleston wrote:
>> On Oct 13, 2009, at 14:48, Peter Hutterer wrote:
>>
>>> On Tue, Oct 13, 2009 at 12:08:53PM -0700, Jeremy Huddleston wrote:
>>>> I'm still holding off branching from master or creating my own
>>>> xserver
>>>> git because I want to read your promised "best practices", so I  
>>>> do it
>>>> correctly.  Have you gotten around to starting that up?
>>>
>>>
>>> http://www.x.org/wiki/XServer
>>> is what we have so far. Let me know what's missing and I'll add it.
>
>
>> Ok, thanks.  Some questions/confusion from someone who isn't a git-
>> expert:
>
> Thanks, I tried to merge your comments into the above page, please  
> have a
> look again. See the diff here http://www.x.org/wiki/XServer? 
> action=diff
>
>> ---
>>
>> In "Scooping", Shouldn't we be using 'git fetch origin; git rebase
>> origin/master' rather than 'git pull origin'?
>>
>> Is 'git pull --rebase' the same thing as 'git fetch; git rebase
>> _______'?
>
> yes, 'git pull --rebase origin' is the same as 'git fetch origin;  
> git rebase
> origin/master'.
> you can set up hooks for each repo to tell it what it means when you  
> don't
> specify the remote but I've gotten used to always supplying the  
> remote.
> IIRC you can also set git up that git pull --rebase rebases a  
> diffent branch
> but I don't know how to do that - never needed to.
>
>> I guess I'm just confused about pull.
>
> please look, I hope I explained now when to rebase and when to pull  
> but I
> didn't add a full documentation on pull/rebase - this isn't the  
> right page
> for it.
>
>> ---
>>
>> How can I get email sent for pushes to my personal git?  (eg: I'd  
>> like
>> to have mail sent to xquartz-changes at lists.macosforge.org)
>
> in your fdo repository, edit .git/hooks/update.
> (look at /srv/anongit.freedesktop.org/git/xorg/xserver.git/hooks/ 
> update
> on annarchy for the xorg-commits email generation)
>
>> ---
>>
>> When I'm on my local branch, how do I make it so master pushes to my
>> tree on anarchy?  Assume I've done:
>>
>> git clone ssh://git.freedesktop.org/git/xorg/xserver
>> cd xserver
>> git remote jeremyhu ssh://git.freedesktop.org/~jeremyhu/xserver.git
>            ^^ git remote add
>> git push jeremyhu master
>> # edit some files
>> git commit -a
>> git push # will this send my local master to origin/master or  
>> jeremyhu/
>> master?  How can I make it use jeremyhu/master if it's still origin/
>> master?
>
> push without a remote always pushes to origin (git.freedesktop.org)
> IIRC in older versions of git that even pushed all local branches to  
> the
> remote, hence why I started always using explicit remotes and  
> branches.
> so in the future you should always use git push <remote> <branch>,  
> pushes
> your local branch to remote/branch.
>
> the safest way is to clone origin anongit, that way you can't  
> accidentally
> push into it (though that stops you from pushing into 1.7- 
> nominations as
> well of course).
>
> so, back to start - does the wiki page answer the questions now?
>
> Cheers,
>  Peter
> _______________________________________________
> xorg-devel mailing list
> xorg-devel at lists.x.org
> http://lists.x.org/mailman/listinfo/xorg-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5820 bytes
Desc: not available
Url : http://lists.x.org/archives/xorg-devel/attachments/20091013/41bb01a1/attachment.bin 


More information about the xorg-devel mailing list