Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Checkout assigned branch (or default to master) when commit ref matches HEAD. #1164

stevelacey opened this Issue Oct 1, 2012 · 6 comments


None yet
5 participants

When Composer updates a package it leaves the local repo for it in a detached HEAD state rather than on a particular branch, for good reasons.

This is fine for third-party packages you're not going to be editing often if at all, but when you're doing a lot of work in bundles as part of a team, naturally, you find yourself doing composer update quite a lot– it would be great if there was a more reliable workaround to having to remember to checkout master first / merge in when you forget.

Perhaps a configurable way to define which packages you want to always be on a particular branch and some kind of comparison of the state of the detached head to that branch?

See: http://stackoverflow.com/questions/12284090/no-branch-when-installing-with-composer-json/12284689#comment17059215_12284689

@Seldaek Seldaek closed this in 3068f29 Oct 17, 2012


Seldaek commented Oct 17, 2012

Fixed, as said though it'll only do it when the commit you're checking out is the latest commit of the branch, it might be possible to do it for older commits but I think it's a bit dangerous, we'll see later if it's still a big inconvenience.


ronnylt commented Oct 17, 2012

Does not work consistently for me. With the following deps, composer leaves "doctrine/dbal" in the correct (2.3) branch, but "predis/predis" still is in a detached branch.

"require": {
    "predis/predis": "0.7.x-dev",
    "doctrine/dbal": "2.3.x-dev",
    "mockery/mockery": "dev-master"

Thanks for your support.


Seldaek commented Oct 19, 2012

@ronnylt ok fixed that, it was an issue with non-master branches. Now it should check out branches for everything but tagged releases.

Great improvement :)


ricardclau commented Oct 19, 2012

@Seldaek Thank you so much for this. We work on a project with several bundles created by ourselves and this was a bit annoying when we updated dependencies.


Seldaek commented Oct 19, 2012

No worries, beware though that it is rolling back the branch to an older state, so if you force-push you will destroy commits. Be sure to pull/rebase before pushing.

@digitalkaoz digitalkaoz pushed a commit to digitalkaoz/composer that referenced this issue Nov 22, 2013

@Seldaek Seldaek Checkout branch by name when the current reference matches the branch…
… tip, fixes #1164

@digitalkaoz digitalkaoz pushed a commit to digitalkaoz/composer that referenced this issue Nov 22, 2013

@Seldaek Seldaek Add missing v before checkout branches when needed, refs #1164 eaf0fff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment