No your 3rd point is incorrect (the other 2 are ok). It’s merge, OR merge -squash, OR rebase your changes onto the destination. Once your commits have been moved to Main via rebasing there is no Merge following it (it wouldn’t do anything if there was - it would be empty, as your two branches would be exactly the same at that point. This is merge -ff Answer from jibbit on reddit.com
🌐
Git
git-scm.com › docs › git-merge
Git - git-merge Documentation
By default, git merge command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently.
🌐
W3Schools
w3schools.com › git › git_branch_merge.asp
Git Branch Merge
To combine the changes from one branch into another, use git merge.
🌐
Git
git-scm.com › book › en › v2 › Git-Branching-Basic-Branching-and-Merging
Git - Basic Branching and Merging
Suppose you’ve decided that your ... your hotfix branch earlier. All you have to do is check out the branch you wish to merge into and then run the git merge command:...
🌐
GitHub
docs.github.com › articles › merging-a-pull-request
Merging a pull request - GitHub Docs
To learn more about GitHub CLI, see About GitHub CLI. To merge a pull request, use the gh pr merge subcommand. Replace pull-request with the number, URL, or head branch of the pull request.
🌐
GitHub
cli.github.com › manual › gh_pr_merge
GitHub CLI | Take GitHub to the command line
To bypass a merge queue and merge directly, pass the --admin flag.
🌐
Reddit
reddit.com › r/git › what are the exact git commands github uses when merging a pr?
r/git on Reddit: What are the exact git commands Github uses when merging a PR?
February 3, 2023 -

So there's 3 options when merging a PR in Github:

  1. Create a merge commit

  2. Squash and merge

  3. Rebase and merge

Just looking at https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges, I still had a few questions on exactly what git commands Github is using when merging a PR.

Create a merge commit

Is this just git merge --no-ff?

It looks like you'll always have a merge commit, regardless whether the PR branch had diverged or not.

Squash and merge

Is this squashing commits (git rebase -i) and then git merge or git cherry-pick?

It looks like for both diverged/non-diverged branches, this always results in your squashed commit going in linearly onto the main branch.

Rebase and merge

This one I'm more confident about. This looks like a git rebase and git merge.

It rebases your feature branch onto main, then merges all the commits in, putting all feature commits into the main branch. This is opposed to the other options which either give you a merge commit or one squashed commit.

Find elsewhere
🌐
Atlassian
atlassian.com › git › tutorials › using branches › git merge
Git Merge | Atlassian Git Tutorial
In the event that you require a merge commit during a fast forward merge for record keeping purposes you can execute git merge with the --no-ff option. ... This command merges the specified branch into the current branch, but always generates ...
🌐
GitHub
docs.github.com › articles › about-merge-methods-on-github
About merge methods on GitHub - GitHub Docs
When using the Rebase and Merge option on a pull request, it's important to note that the commits in the head branch are added to the base branch without commit signature verification. When you use this option, GitHub creates a modified commit, using the data and content of the original commit.
Top answer
1 of 1
18

When working with and closing a pull request you have three merge options Create a merge commit, Squash and merge and Rebase and merge. I wonder how these options translate into actual Git commands - especially with regards to --no-ff.

  • The GitHub "make a merge" button corresponds to:

    git checkout <branch>
    git merge --no-ff -m <message> <commit-hash>
    

    where the message part is something you'd have to generate by hand, since your local Git does not know the details of the pull request (its number, and any other repository). The branch part is your target branch: the one you want the merge commit to be on, after the merge completes.

    Note that you must have the specified commit-hash commit object in your repository at this point. GitHub's behind-the-scenes manipulation means that it is available in the Git repository on GitHub, but it's listed under a refs/pull/ reference, rather than a branch name, in that repository.

  • The GitHub "squash and merge" button corresponds to:

    git checkout <branch>
    git merge --squash <commit-hash>
    git commit
    

    with the git commit being required because the command-line --squash flag turns on the command-line --no-commit flag.

  • The GitHub "rebase and merge" button corresponds—somewhat roughly—to:

    # maybe: create a branch name (consider using git checkout -b next)
    git checkout <commit-hash-or-branch-name>
    git rebase <branch>
    git checkout <branch>
    git merge --ff-only <hash-or-name>
    # maybe: delete a branch name
    

    This is the most complicated one: the commit-hash-or-name is either the commit hash ID that you would supply to the other two, or a branch name that identifies that commit hash ID, preferably a temporary name you just made up for the duration of this operation. The git rebase operation must then succeed on its own—if not, GitHub itself won't offer you the ability to do a rebase-and-merge.

    If the rebase operation does succeed and you chose to do it with a detached HEAD, you must now save the hash ID of the rebased commit. If you chose to do it using some temporary branch name, nothing special is required at this point.

    Now that the original chain of commits has been copied by the rebase operation, now you git checkout the branch you want to update-by-fast-forward and run the git merge --ff-only operation. The name or hash ID you supply here is the one that the successful rebase operation either produced as the tip of the detached HEAD, or updated into the temporary branch name.

    If you used a temporary branch name, you should now delete that temporary branch name.

🌐
Git Tower
git-tower.com › learn › git faq › how to merge branches in git with git merge
How to Merge Branches in Git with git merge | Learn Version Control with Git
1 week ago - Merge a branch into your current branch with git merge. Covers fast-forward merges, no-fast-forward merges, and resolving merge conflicts.
🌐
GitHub
github.com › marketplace › actions › pull-request-merge-command
Pull request merge command - GitHub Marketplace
name: 'Merge command' on: issue_comment jobs: merge-command: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v1 - name: Merge command uses: Goobles/gh-actions-merge-command@v1 with: allow_ff: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
🌐
GitHub
gist.github.com › a5c460364089e2138e036738f1b5eb75
Github merging via command line · GitHub
Clone this repository at &lt;script src=&quot;https://gist.github.com/temptemp3/a5c460364089e2138e036738f1b5eb75.js&quot;&gt;&lt;/script&gt;
🌐
GitHub
docs.github.com › en › pull-requests › collaborating-with-pull-requests › incorporating-changes-from-a-pull-request › merging-a-pull-request-with-a-merge-queue
Merging a pull request with a merge queue - GitHub Docs
With GitHub CLI, use the gh pr merge command to add a pull request to a merge queue. If you are targeting a branch that requires a merge queue, this command automatically adds the pull request to the queue if required checks have passed.
🌐
GitHub
gist.github.com › aortbals › 2aeb557bf127dd7ae88ea63da93479fc
Squash and Merge on the Command line · GitHub
You want to create a single squashed commit to push to your remote feat-fuu branch on GitHub. ... You are deleting your original branch. Ensure you have created feat-fuu-backup beforehand and it has your full commit history. ... You are merging and squashing your original work into a single commit.
🌐
GitHub
github.blog › home › developer skills › github education › beginner’s guide to github: merging a pull request
Beginner’s guide to GitHub: Merging a pull request - The GitHub Blog
August 26, 2024 - Back in the terminal, run the following commands to commit your changes and verify that all of the changes have been committed: git add . git commit -m "resolve merge conflict" git status · https://github.blog/wp-content/uploads/2024/08/07...
🌐
GitHub
docs.github.com › en › pull-requests › how-tos › merge-and-close-pull-requests › resolving-a-merge-conflict-using-the-command-line
Resolving a merge conflict using the command line - GitHub Docs
You can now merge the branches on the command line or push your changes to your remote repository on GitHub and merge your changes in a pull request.
🌐
Varonis
varonis.com › blog › git-branching
Git Branching and Merging: A Step-By-Step Guide
September 12, 2025 - This action means your branch is now out of date of the main branch and missing content. You can merge the main branch into your branch by checking out your branch and using the same git merge command.
Top answer
1 of 1
1

To merge a pull request (PR) using the GitHub CLI (gh), follow these steps:

Install GitHub CLI (if not already installed):

You can download and install it from GitHub CLI releases or via a package manager (e.g., brew install gh for macOS, or sudo apt install gh for Ubuntu).
Authenticate with GitHub:

Run gh auth login to authenticate. You can choose to authenticate via web browser or by pasting an authentication token.
Navigate to Your Repository:

If you're not already in the directory of your repository, navigate to it using:
sh
Copy code
cd path/to/your/repository
View the List of Pull Requests:

To view open pull requests, you can use:
sh
Copy code
gh pr list
Check Out the Pull Request (optional but recommended):

If you want to review the changes locally, you can check out the pull request branch:
sh
Copy code
gh pr checkout
Replace with the number of the pull request.
Merge the Pull Request:

To merge the pull request, use:
sh
Copy code
gh pr merge
This command will prompt you to choose a merge method (merge, squash, rebase). You can specify the method directly with a flag:
Merge: --merge
Squash and Merge: --squash
Rebase and Merge: --rebase
Example:
sh
Copy code
gh pr merge --merge
If you want to skip the confirmation prompt, you can add --auto:
sh
Copy code
gh pr merge --merge --auto
Push the Changes (if required):

If you opted to checkout and test the PR locally, remember to push the merged changes back to the main branch, if not automatically done by the gh pr merge command:
sh
Copy code
git push origin main
Example Workflow:

sh
Copy code
gh auth login
cd path/to/your/repository
gh pr list
gh pr checkout 42 # assuming PR #42

Review the changes

gh pr merge 42 --merge # merges with a merge commit
That's it! The pull request should now be merged.

🌐
Barbagroup
barbagroup.github.io › essential_skills_RRC › git › branching
Branch and Merge - Essential skills for reproducible research computing
Sometimes, you might want to force git to create a merge commit, so that you know where a branch was merged in. In that case, you can prevent git from doing a "fast-forward" by merging with the -no-ff flag. (note that this command won't work now that we have already merged in make_function)
🌐
Uidaholib
uidaholib.github.io › digital-collections-docs › content › maintainers › merging.html
Merging Main into Branch | Digital Collections Docs
In the Branches dropdown on GitHub Desktop, click the bottom button that says “Choose a branch to merge into [whatever branch you’re on],” and choose the “main” branch. Once you select “main,” the merge will begin. In some cases there will be conflicting files, and you’ll need to click a button that accepts this to continue the merge. Command line: in VS Code terminal ensure you are on the correct branch git status ·