Skip to contentSkip to conversation

OT: git workflow question

Buildroot Grant Edwards 6 participants 9 messages Dec 16, 2009 – Dec 17, 2009

lore
Share & tools
lore
#0 lore raw

I don't seem to "get" git when it comes to working with buildroot.

1) I cloned the repository about two weeks ago

2) I made a bunch of small edits to docs/buildroot.html and commited them locally.

3) I submitted the changes using git format-patch

4) The patches were merged to the "master" repository

5) Then when I did a "git pull" to update my repository, it failed because of conflicts in docs/buildroot.html

Since I had only changed the one file (and those changes had been merged into the master repository) I didn't bother trying to resolve the conflict -- I just blew away my repository and did a 'clone'.

Here's my question: why was there a conflict?

Is this how git is supposed to work?

Signature · 3 lines
Grant Edwards                   grante             Yow! I'm ZIPPY the PINHEAD
                                  at               and I'm totally committed
                               visi.com            to the festive mode.
#1 lore raw

Le Wed, 16 Dec 2009 16:53:24 +0000 (UTC), Grant Edwards <[email protected]> a ?crit :

Quoted 6 lines

Since I had only changed the one file (and those changes had been merged into the master repository) I didn't bother trying to resolve the conflict -- I just blew away my repository and did a 'clone'.

Here's my question: why was there a conflict?

Not sure why, Peter will probably give an explanation.

Quoted 1 line

Is this how git is supposed to work?

No. You should have made your changes in a separate branch instead of a master branch. Then, you submit your patches. When they are merged, you do "git pull" in your master branch. And then "git branch -d yourbranch". If everything has been merged, "git branch -d" will succeed, otherwise it will fail (and you can use "git branch -D" to remove a branch that hasn't been merged).

This is at least how I'm contributing to Buildroot. Not necessarly the cleanest way, I'm no git expert.

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#2 lore raw
Quoted 11 lines · Thomas Petazzoni

Le Wed, 16 Dec 2009 16:53:24 +0000 (UTC), Grant Edwards <[email protected]> a ??crit :

Quoted 6 lines

Since I had only changed the one file (and those changes had been merged into the master repository) I didn't bother trying to resolve the conflict -- I just blew away my repository and did a 'clone'.

Here's my question: why was there a conflict?

Not sure why, Peter will probably give an explanation.

That question has been answered.

Quoted 4 lines
Quoted 1 line

Is this how git is supposed to work?

No. You should have made your changes in a separate branch instead of a master branch.

Thanks. That's the clue I was missing. The tutorials I had read on git didn't say that -- they showed all work being done in the master branch.

Quoted 8 lines

Then, you submit your patches. When they are merged, you do "git pull" in your master branch. And then "git branch -d yourbranch". If everything has been merged, "git branch -d" will succeed, otherwise it will fail (and you can use "git branch -D" to remove a branch that hasn't been merged).

This is at least how I'm contributing to Buildroot. Not necessarly the cleanest way, I'm no git expert.

I certainly sounds like a better approach that what I was doing.

Signature · 3 lines
Grant Edwards                   grante             Yow! !  Now I understand
                                  at               advanced MICROBIOLOGY and
                               visi.com            th' new TAX REFORM laws!!
#3 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Grant" == Grant Edwards <[email protected]> writes:

Hi,

Quoted 2 lines
Quoted 2 lines

No. You should have made your changes in a separate branch instead of a master branch.

Grant> Thanks. That's the clue I was missing. The tutorials I had Grant> read on git didn't say that -- they showed all work being done Grant> in the master branch.

That can work for quick edits, but then you need to remove the commit before pulling updates in (git reset --hard origin/master). I would recommend just creating a branch instead though as it's so easy/fast to do in git (and it allows you to use git-rebase).

Quoted 2 lines
Quoted 2 lines

This is at least how I'm contributing to Buildroot. Not necessarly the cleanest way, I'm no git expert.

Grant> I certainly sounds like a better approach that what I was doing.

And it's what I would consider the "normal" way of working (it's atleast how I do it when I contribute something to a project using git).

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw
In reply to Thomas Petazzoni

Thomas Petazzoni, 2009-12-16:

Quoted 4 lines
Quoted 1 line

Is this how git is supposed to work?

No. You should have made your changes in a separate branch instead of a master branch.

I don't think this is always necessary. Depending on the amount of changes he is working on, working on one branch and rebasing against origin is sufficient and may be the better approach.

Quoted 4 lines

Then, you submit your patches. When they are merged, you do "git pull" in your master branch. And then "git branch -d yourbranch". If everything has been merged, "git branch -d" will succeed,

No, it will never succeed for him, because Peter applies his patches. It works for you, because Peter doesn't apply patches from you, but merges your branches. So the commit SHA1 stays the same in your case.

Markus

#5 lore raw
In reply to Thomas Petazzoni

Hello,

Thomas Petazzoni a ?crit :

Quoted 11 lines

No. You should have made your changes in a separate branch instead of a master branch. Then, you submit your patches. When they are merged, you do "git pull" in your master branch. And then "git branch -d yourbranch". If everything has been merged, "git branch -d" will succeed, otherwise it will fail (and you can use "git branch -D" to remove a branch that hasn't been merged).

This is at least how I'm contributing to Buildroot. Not necessarly the cleanest way, I'm no git expert.

Could someone update the Buildroot documentation to explain the workflow for contributing efficiently to the project ?
I'm a newbie with git and it takes me significant time when I want to share my work with you.
So I'm pretty sure top contributors have tips to not gather and send patches manually ;-)

Regards,
Julien

#6 lore raw
In reply to Grant Edwards
Quoted 4 lines · Grant Edwards

Here's my question: why was there a conflict?

Is this how git is supposed to work?

Chances are you changes got massaged on the way in, either intentionally or by some script/git configuration (whitespace.strip catches me out a lot). Some maintainers I've seen on other projects insist that patches are perfect before they apply them. From what I've seen Peter is a bit more pragmatic and is happy to make small changes/amendments to patches as they get applied.

When you pull from the upstream buildroot git sees both sets of changes and flags them as a conflict.

The best advice would be to work on local branches for logical sets of changes (in my case I've just got one branch because I'm only tinkering with buildroot). You can then rebase (git rebase origin/master <branch> or git pull --rebase) these branches or blow them away when you're done (git branch -d <branch>). Git also has a merge helper (git mergetool) which can be configured with a graphical diff tool like kdiff3 to make resolving merges easier.

#7 lore raw
In reply to Grant Edwards

Grant Edwards, 2009-12-16:

Quoted 8 lines

I don't seem to "get" git when it comes to working with buildroot.

1) I cloned the repository about two weeks ago

2) I made a bunch of small edits to docs/buildroot.html and commited them locally.

Quoted 6 lines

3) I submitted the changes using git format-patch

4) The patches were merged to the "master" repository

5) Then when I did a "git pull" to update my repository, it failed because of conflicts in docs/buildroot.html

If you don't have problems with rewritten history, then "git rebase" may suit your needs better. Can also be used with "git pull --rebase".

Quoted 4 lines

Since I had only changed the one file (and those changes had been merged into the master repository) I didn't bother trying to resolve the conflict -- I just blew away my repository and did a 'clone'.

You should never need to do a fresh clone. Read about "git reset --hard" for escaping from a mess.

Quoted 1 line

Here's my question: why was there a conflict?

I'm aware of 2 possible reasons:
Either Peter has fixed something in your patch before he committed it or commit 16c1549fd22af9a5fedd98d173a4c229b909af4c, which touched the same file afterwards, caused the conflict.

Markus

#8 lore raw
Quoted 6 lines · Markus Heidelberg

Grant Edwards, 2009-12-16:

Quoted 1 line

Here's my question: why was there a conflict?

I'm aware of 2 possible reasons: Either Peter has fixed something in your patch before he committed it

That is what happened. He combined two patches into a single commit (he may have fixed other things as well).

Signature · 3 lines
Grant Edwards                   grante             Yow! What GOOD is a
                                  at               CARDBOARD suitcase ANYWAY?
                               visi.com