Require specific commit and branch from GitHub with Composer

If you need to include specific branch and/or specific commit from GitHub into your project via Composer use following syntax:

{
	"minimum-stability": "dev", 
	"require": {
		"vendor/package": "dev-branchname#6bdd====full commit id====a9c6",
		}
	,
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/user/repo.git"
        }
    ]
}
  • branch name gets always dev- in front (so branch “features” translates to “dev-features”)
  • you can load specific commit with # followed by the desired commit id