Skip to main content

Config

GIT

Overview

An overview of the process for contributors is:

  • Clone the project repository.
  • Create a new branch.
  • Make code changes.
  • Commit the code changes within the newly created branch.
  • Push the branch to the forked repository.
  • Submit a pull request to the project repository.

Branch Naming

You should name your branches using a prefixes and short description, like this: [type]/[change].

Suggested prefixes:

  • add/ = add a new feature
  • try/ = experimental feature, “tentatively add”
  • update/ = update an existing feature
  • remove/ = remove an existing feature
  • fix/ = fix an existing issue

For example, add/gallery-section means you’re working on adding a new gallery section.

Keeping Your Branch Up To Date

When many different people are working on a project simultaneously, pull requests can go stale quickly. A “stale” pull request is one that is no longer up to date with the main line of development, and it needs to be updated before it can be merged into the project.

There are two ways to do this: merging and rebasing. In Gutenberg, the recommendation is to rebase. Rebasing means rewriting your changes as if they’re happening on top of the main line of development. This ensures the commit history is always clean and linear. Rebasing can be performed as many times as needed while you’re working on a pull request. Do share your work early on by opening a pull request and keeping your history rebase as you progress.

The main line of development is known as the trunk branch. If you have a pull-request branch that cannot be merged into trunk due to a conflict (this can happen for long-running pull requests), then in the course of rebasing you’ll have to manually resolve any conflicts in your local copy. Learn more in section Perform a rebase of How to Rebase a Pull Request.

Once you have resolved any conflicts locally you can update the pull request with git push --force-with-lease. Using the --force-with-lease parameter is important to guarantee that you don’t accidentally overwrite someone else’s work.

To sum it up, you need to fetch any new changes in the repository, rebase your branch on top of trunk, and push the result back to the repository. These are the corresponding commands:

  • git fetch
  • git rebase trunk
  • git push --force-with-lease origin your-branch-name