Skip to content

Instantly share code, notes, and snippets.

@yugaego
Last active January 13, 2024 14:52
Show Gist options
  • Save yugaego/4a07d77af36053925314f02d120b16ea to your computer and use it in GitHub Desktop.
Save yugaego/4a07d77af36053925314f02d120b16ea to your computer and use it in GitHub Desktop.
Fork and Branch Git Workflow Cheat Sheet. How to use (+require by composer) and maintain forked library, contributing updates to the main library repository.

MAKE FORK

  • github.com: click Fork button
  • git clone fork-git-url
  • git remote add upstream parent-repo-url

WORK WITH FORK

  • git checkout -b new-feature-branch
  • git add .
  • git commit -m “short yet descriptive message”
  • git push origin new-feature-branch

PULL REQUEST

  • possibly git rebase
  • github.com: click New pull request button

AFTER PULL REQUEST MERGE

  • git branch -d merged-feature-branch
  • git push --delete origin merged-feature-branch

PARENT REPO SYNCING TO A FORK

Detailed
  • git fetch upstream
  • git checkout master
  • git merge upstream/master
  • git push origin master
Fast
  • git pull upstream master
  • git push origin master

COMPOSER

{
    "repositories": [
        {
            "type": “git",
            "url": “fork-git-url"
        }
    ],
    "require": {
        “parent/name": "dev-bugfix"
    }
}

Based On

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment