github

How to merge branches on github.com without doing pull request?


It looks like GitHub only allows merging of branches by making a pull request and then merging.

Is there a way to merge mobile into main in a single step without cloning locally?

I only see this button, which creates a pull request that needs to be merged in a second step:

Compare, review, create a pull request

Solution

  • You can use GitHub Docs' GraphQL API Explorer to run a mergeBranch mutation:

    mutation {
      mergeBranch(
        input: {
          repositoryId: "MDEwOlJlcG9zaXRvcwNzI="
          base: "master"
          head: "cool_feature"
          commitMessage: "Shipped cool_feature!"
        }
      ) {
        clientMutationId
        mergeCommit {
          oid
          message
        }
      }
    }
    

    Note: You can look up your repository's id by using the repository query to search by owner and name.

    {
      repository(owner: "my-name", name: "my-repo") {
        id
      }
    }