# Git merging fun and a local clone-per branch workflow

- Thread: https://externals.io/message/59127
- Original archive: https://news-web.php.net/php.internals/59127
- Started by Christopher Jones on 2012-03-22T23:24:26+00:00
- Messages: 11
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #59127 — Christopher Jones — 2012-03-22T23:24:26+00:00

URL: https://externals.io/message/59127#59127

1. I had fun with a couple of small git merges today.  I was trying to
    use local clones as briefly outlined on irc by dsp.  The goal is to
    have different local directories for each of the three branches:
    5.3, 5.4 and 'trunk'.  The resulting pushes I made today are a
    little strange and need reviewing/reverting.  For example my
    oci8/README fix doesn't seem to have got merged to 5.3.  At some
    stage somehow '21 commits' got merged to PHP 5.4.  I swear 'git
    diff' was only showing my changes.

2. Long term, to document the desired steps (as opposed to those I was
    doing), Alexey Shein worked out some scenarios:

        https://gist.github.com/2165086

    He prefers the 2nd set 'README-3'. These steps are untested and
    there may still be issues with handling NEWS.  Suggestions welcome.
    Note these use https for my behind-a-firewall situation.

Chris

PS dsp is (or should be) busy with studying, so there might be a
hiatus or slow down for git migration.


-- 
Email: christopher.jones@oracle.com
Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

---

## #59128 — Kiall Mac Innes — 2012-03-23T00:09:12+00:00

URL: https://externals.io/message/59127#59128 · In reply to: #59127

On Thu, Mar 22, 2012 at 11:24 PM, Christopher Jones <
christopher.jones@oracle.com> wrote:

> 1. I had fun with a couple of small git merges today.  I was trying to
>   use local clones as briefly outlined on irc by dsp.


Multiple clones for each branch will be *much **much* harder to manage from
a Git POV.

From a build POV though, it might be easier as you can avoid lots of `make
clean` etc..


> The goal is to
>   have different local directories for each of the three branches:
>   5.3, 5.4 and 'trunk'.  The resulting pushes I made today are a
>   little strange and need reviewing/reverting.  For example my
>   oci8/README fix doesn't seem to have got merged to 5.3.


With multiple local clones, you can end up with some strange situations if
you don't know exactly what you're pushing/pulling between them AND the
central repo..


>  At some stage somehow '21 commits' got merged to PHP 5.4.  I swear 'git
>   diff' was only showing my changes.
>

Right - `git diff` shows the different between HEAD (The last commit of the
branch your are currently on) and what you have yet to commit.

So - When you then merge $current_branch into $other_branch, the merge will
merge all commits from $current_branch into $other_branch, not just your
own..

eg:

$ git checkout PHP-5.3
# Edit some files
$ git commit ..
# Edit some files 2
$ git commit ..
$ git checkout PHP-5.4
$ git merge PHP-5.3

2 commits will be merged - Assuming nobody else has changed 5.3 since the
last time anyone merged it into 5.4

If on the other hand, someone else committed to 5.3, did not merge to 5.4,
and you have that commit in your 5.3 branch.. then the merge will do 3
commits, even though you only made 2.

This is likely what you saw.

`git log --oneline --graph` is a useful command to try and understand what
happened, and what was merged where..

Thanks,
Kiall

---

## #59129 — Christopher Jones — 2012-03-23T00:31:30+00:00

URL: https://externals.io/message/59127#59129 · In reply to: #59128

> Right - `git diff` shows the different between HEAD (The last commit
> of the branch your are currently on) and what you have yet to
> commit.

I was doing the diffs compared with the origin/* branches, as shown in
the gist, https://gist.github.com/2165086

> 2 commits will be merged - Assuming nobody else has changed 5.3 since the last time anyone merged it into 5.4
>
> If on the other hand, someone else committed to 5.3, did not merge to 5.4, and you have that commit in your 5.3 branch.. then the merge will do 3 commits, even though you only made 2.
>
> This is likely what you saw.

Maybe!

At this stage finding the best workflow that allows multiple local
branch directories to co-exist and aligns with PHP's general git
processes is the issue.  I notice Dmitry mentioned git-new-workdir.
Does anyone have a workflow and comments on that (including with
respect to NEWS)?

>
> `git log --oneline --graph` is a useful command to try and understand what happened, and what was merged where..

gitk shows this too.

>
> Thanks,
> Kiall

Thanks for the comments.

Chris

-- 
Email: christopher.jones@oracle.com
Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

---

## #59145 — Alexey Shein — 2012-03-24T12:58:55+00:00

URL: https://externals.io/message/59127#59145 · In reply to: #59129

Hello,

Just wanted to say that I updated multiple working dirs scenario here
https://gist.github.com/2165086/, which is *much* more simplified now,
thanks to dsp for hint about git-new-workdir script.
It should work fine if all changes from downstream branches (such as
PHP-5.3) are always merged into upstream (PHP-5.4).
If it's not the case, then some other solution is needed.


-- 
Regards,
Shein Alexey

---

## #59146 — David Soria Parra — 2012-03-24T13:23:18+00:00

URL: https://externals.io/message/59127#59146 · In reply to: #59145

> Hello,
>
> Just wanted to say that I updated multiple working dirs scenario here
> https://gist.github.com/2165086/, which is *much* more simplified now,
> thanks to dsp for hint about git-new-workdir script.
> It should work fine if all changes from downstream branches (such as
> PHP-5.3) are always merged into upstream (PHP-5.4).
> If it's not the case, then some other solution is needed.

Can you pleae add a description like that to the php wiki ?

---

## #59149 — Alexey Shein — 2012-03-24T15:30:36+00:00

URL: https://externals.io/message/59127#59149 · In reply to: #59146

24 марта 2012 г. 18:23 пользователь David Soria Parra <dsp@php.net> написал:
> 
> > […]
>
> Can you pleae add a description like that to the php wiki ?

Done. https://wiki.php.net/vcs/gitfaq#multiple_working_copies_workflow

> --
> 
> 
>



-- 
Regards,
Shein Alexey

---

## #59151 — Christopher Jones — 2012-03-24T16:03:59+00:00

URL: https://externals.io/message/59127#59151 · In reply to: #59149

> 24 марта 2012 г. 18:23 пользователь David Soria Parra<dsp@php.net>  написал:
> > […]
>
> Done. https://wiki.php.net/vcs/gitfaq#multiple_working_copies_workflow
>
> > […]
>
>
>

Nice work Alexey.

Can you expand on the "if necessary" part of the setting the
pushurl?

My sense of completeness makes me think the content of your
text should be in the wiki, so it can be updated by anyone
in the future.

Chris

-- 
Email: christopher.jones@oracle.com
Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

---

## #59152 — Alexey Shein — 2012-03-24T18:17:27+00:00

URL: https://externals.io/message/59127#59152 · In reply to: #59151

> Nice work Alexey.
>
> Can you expand on the "if necessary" part of the setting the
> pushurl?

I removed that part and added some explanation about clone urls in the
beginning. Since this workflow is generally for core devs ssh/https
are read/write so you don't need separate setting push-urls.

> My sense of completeness makes me think the content of your
> text should be in the wiki, so it can be updated by anyone
> in the future.
>

Done: https://wiki.php.net/vcs/gitfaq#multiple_working_copies_workflow

>
> Chris
>
> --
> Email: christopher.jones@oracle.com
> Tel:  +1 650 506 8630
> Blog:  http://blogs.oracle.com/opal/
>
> --
> 
> 
>



-- 
Regards,
Shein Alexey

---

## #59153 — Christopher Jones — 2012-03-24T18:47:56+00:00

URL: https://externals.io/message/59127#59153 · In reply to: #59152

> > […]
> I removed that part and added some explanation about clone urls in the
> beginning. Since this workflow is generally for core devs ssh/https
> are read/write so you don't need separate setting push-urls.
>
> > […]
> Done: https://wiki.php.net/vcs/gitfaq#multiple_working_copies_workflow
>

Thanks!

Chris

-- 
Email: christopher.jones@oracle.com
Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

---

## #59186 — Christopher Jones — 2012-03-27T19:18:45+00:00

URL: https://externals.io/message/59127#59186 · In reply to: #59152

> Done: https://wiki.php.net/vcs/gitfaq#multiple_working_copies_workflow

I tried it out today.  It mostly went smoothly.

Because of differing file contents in the branches (from my merge
attempts last week) I had to resolve conflicts when merging to
~/php-src.  I did a 'git commit -a' to resolve it. Was this the
easiest way?  If so I will add it to the workflow.

When pushing I got:

   error: Cannot access URL https://git.php.net/repository/php-src.git/, return code 22

This was resolved after doing:

   cd ~/php-src
   git config remote.origin.pushurl https://git.php.net/push/php-src.git/

We were having chronic firewall failures while I was doing this, but I
believe the above pushurl solved this particular issue.  I guess the
wording "These both are push-urls" only really applies to the
git@git.php.net:php-src.git resource.  Can you confirm this (before I
update the wiki)?

Thanks,

Chris

-- 
Email: christopher.jones@oracle.com
Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

---

## #59187 — Alexey Shein — 2012-03-27T20:16:00+00:00

URL: https://externals.io/message/59127#59187 · In reply to: #59186

28 марта 2012 г. 0:18 пользователь Christopher Jones
<christopher.jones@oracle.com> написал:
>
>
> 
>
> > […]
>
>
> I tried it out today.  It mostly went smoothly.

Hi! Glad to hear that.

> Because of differing file contents in the branches (from my merge
> attempts last week) I had to resolve conflicts when merging to
> ~/php-src.  I did a 'git commit -a' to resolve it. Was this the
> easiest way?  If so I will add it to the workflow.

This is the common technique afaik. If you get the conflict, you
should resolve it somehow (manually or using some merge tools), after
that to get know git about you're done, use
$ git add <files with conflicts>
Be sure to resolve all conflicts, watch out <<<<< and >>>> strings in
conflicted files, there shouldn't be any.
$ git commit -m 'Resolved merging conflict'

Generally, resolving conflicts in public branches is not a good idea.
You'll get very messy branch history. Instead, you should resolve
conflicts when rebasing your own private branches against up-to-date
public ones. This way your branch becomes "a patch to repository HEAD"
which is very clean and nice to see.

> When pushing I got:
>
>  error: Cannot access URL https://git.php.net/repository/php-src.git/,
> return code 22
>
> This was resolved after doing:
>
>  cd ~/php-src
>  git config remote.origin.pushurl https://git.php.net/push/php-src.git/
>
> We were having chronic firewall failures while I was doing this, but I
> believe the above pushurl solved this particular issue.  I guess the
> wording "These both are push-urls" only really applies to the
> git@git.php.net:php-src.git resource.  Can you confirm this (before I
> update the wiki)?

Yes, it seems I messed up with those http urls.
https://git.php.net/repository/php-src.git - is read-only
https://git.php.net/push/php-src.git/ - is push-only

So you've done everything right, sorry for confusion. Could you update
the wiki, please?
-- 
Regards,
Shein Alexey
