如何在GitHub中使用分叉


How to work on a fork in GitHub

我想在GitHub中更新一个repo,使其与ZF3兼容,我已经将存储库分叉到我的帐户,并进行了一些更新。

这是我的叉子:https://github.com/chateaux/zf-oauth2-doctrine

现在,为了将其包含在我的代码库中,我正在使用Composer:

 {
    "name": "My Project",
    "description": "",
    "license": "PRIVATE - ",
    "keywords": [
        ""
    ],
    "homepage": "",
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/chateaux/zf-oauth2-doctrine"
        }
    ],
    "require": {
        "php": ">=5.4",
        "zendframework/zendframework": "^2.4",
        "doctrine/doctrine-orm-module": "~0.8",
        "doctrine/orm": "^2.4",
        "gedmo/doctrine-extensions": "^2.4",
        "zf-commons/zfc-rbac":"^2.5",
        "rwoverdijk/assetmanager": "^1.4",
        "zfcampus/zf-apigility": "^1.0",
        "zfr/zfr-cors": "^1.2",
        "hounddog/doctrine-data-fixture-module": "^0.0.4",
        "zfcampus/zf-oauth2-client": "dev-master",
        "api-skeletons/zf-oauth2-doctrine": "dev-master",
        "api-skeletons/zf-oauth2-doctrine-console": "^1.1",
        "chateaux/toolbox" : "dev-master"
    },
    "require-dev": {
        "zfcampus/zf-apigility-admin": "~1.0",
        "zfcampus/zf-development-mode": "~2.0",
        "zendframework/zend-developer-tools": "dev-master"
    }
}

然而,当我运行composer更新时,它似乎是从缓存中提取的,所以我没有得到更新的代码库:

$ php composer.phar update
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Warning: This development build of composer is over 60 days old. It is recommended to update it by running "composer.phar self-update" to get the latest version.
Loading composer repositories with package information
Updating dependencies (including require-dev)                               
  - Installing zfcampus/zf-oauth2-doctrine (1.0.3)
    Loading from cache

我做错了什么?

您应该将存储库的自定义分支添加到composer.json文件中的存储库数组中,并添加类型字段git,然后指向要与dev-[branchname]一起使用的分支(例如patch-4变为dev-patch4):

{
    "name": "My ZF2 application",
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/chateaux/zf-oauth2-doctrine.git"
        },
    ],
    "require": {
        ...
        "zfcampus/zf-oauth2-doctrine": "dev-patch-4",
        ...
    }
}

确保patch-4是自定义存储库中的现有分支。

你可以在谷歌的第一次点击中找到更多关于这个解决方案的信息。