Github Review Collapse Commits Into a Single One

When you click the default Merge pull request option on a pull asking on your GitHub Enterprise Server instance, all commits from the feature branch are added to the base branch in a merge commit. The pull request is merged using the --no-ff option.

To merge pull requests, you must take write permissions in the repository.

standard-merge-commit-diagram

Squash and merge your pull asking commits

When yous select the Squash and merge option on a pull request on your GitHub Enterprise Server case, the pull request'due south commits are squashed into a single commit. Instead of seeing all of a correspondent's private commits from a topic co-operative, the commits are combined into 1 commit and merged into the default branch. Pull requests with squashed commits are merged using the fast-frontwards option.

To squash and merge pull requests, yous must have write permissions in the repository, and the repository must allow squash merging.

commit-squashing-diagram

You tin apply squash and merge to create a more than streamlined Git history in your repository. Work-in-progress commits are helpful when working on a feature co-operative, but they aren't necessarily important to retain in the Git history. If y'all squash these commits into ane commit while merging to the default branch, you can retain the original changes with a clear Git history.

Merge bulletin for a squash merge

When you squash and merge, GitHub generates a commit message which you can change if you desire to. The bulletin default depends on whether the pull request contains multiple commits or just ane. We do non include merge commits when we count the total number of commits.

Number of commits Summary Clarification
I commit The title of the commit message for the single commit, followed by the pull asking number The trunk text of the commit message for the single commit
More than than i commit The pull request title, followed by the pull request number A list of the commit letters for all of the squashed commits, in date society

Squashing and merging a long-running branch

If y'all plan to continue work on the head co-operative of a pull request after the pull asking is merged, we recommend you don't squash and merge the pull request.

When you create a pull request, GitHub identifies the nigh recent commit that is on both the head branch and the base co-operative: the common ancestor commit. When you squash and merge the pull asking, GitHub creates a commit on the base branch that contains all of the changes y'all fabricated on the caput co-operative since the mutual ancestor commit.

Because this commit is only on the base of operations branch and non the caput branch, the common ancestor of the two branches remains unchanged. If you continue to work on the head co-operative, then create a new pull request between the ii branches, the pull request will include all of the commits since the common ancestor, including commits that you squashed and merged in the previous pull request. If at that place are no conflicts, y'all can safely merge these commits. However, this workflow makes merge conflicts more probable. If y'all continue to squash and merge pull requests for a long-running caput branch, y'all will accept to resolve the same conflicts repeatedly.

Rebase and merge your pull request commits

When you select the Rebase and merge choice on a pull request on your GitHub Enterprise Server instance, all commits from the topic branch (or caput branch) are added onto the base branch individually without a merge commit. In that way, the rebase and merge behavior resembles a fast-forward merge by maintaining a linear project history. However, rebasing achieves this by re-writing the commit history on the base branch with new commits.

The rebase and merge behavior on GitHub Enterprise Server deviates slightly from git rebase. Rebase and merge on GitHub will e'er update the committer information and create new commit SHAs, whereas git rebase exterior of GitHub does not change the committer information when the rebase happens on top of an antecedent commit. For more data most git rebase, run into git-rebase in the Git documentation.

To rebase and merge pull requests, you must accept write permissions in the repository, and the repository must let rebase merging.

For a visual representation of git rebase, see The "Git Branching - Rebasing" chapter from the Pro Git volume.

You aren't able to automatically rebase and merge on your GitHub Enterprise Server instance when:

  • The pull request has merge conflicts.
  • Rebasing the commits from the base branch into the head branch runs into conflicts.
  • Rebasing the commits is considered "unsafe," such as when a rebase is possible without merge conflicts just would produce a unlike outcome than a merge would.

If yous still want to rebase the commits but tin't rebase and merge automatically on your GitHub Enterprise Server example yous must:

  • Rebase the topic branch (or head branch) onto the base of operations co-operative locally on the control line
  • Resolve any merge conflicts on the command line.
  • Strength-push the rebased commits to the pull request's topic co-operative (or remote head co-operative).

Anyone with write permissions in the repository, can then merge the changes using the rebase and merge push on your GitHub Enterprise Server case.

Farther reading

  • "About pull requests"
  • "Addressing merge conflicts"

payneveteady.blogspot.com

Source: https://docs.github.com/en/enterprise-server@3.3/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges

0 Response to "Github Review Collapse Commits Into a Single One"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel