Feature Request: Only allow for --ff merges for PRs #4618
Replies: 110 comments 74 replies
-
Another reason for supporting actual fast forward merges is that if a user has signed their commits, it will ensure those signatures are kept as part of the merge process. Right now the only solution for maintaining these signatures is to create a merge commit. This obviously isn't an "answer" but apparently I have no other way of adding my feedback to this. |
Beta Was this translation helpful? Give feedback.
-
Related: (Kudos to my colleague, @lekob, who collected these.) |
Beta Was this translation helpful? Give feedback.
-
The issue title is a bit weird. To me a good idea would be like this:
|
Beta Was this translation helpful? Give feedback.
-
As a workaround, here's two workflows that allow fast-forwarding either via commenting
You will need to set up an empty GitHub app for the purpose of generating access tokens. The default token that comes with a workflow,
Fast-forward via commenting `/fast-forward`name: Fast-forward
on:
issue_comment:
types: [created, edited]
jobs:
fast_forward:
name: Fast-forward
runs-on: ubuntu-latest
if: |
github.event.issue.pull_request &&
github.event.comment.author_association == 'OWNER' &&
contains(github.event.comment.body, '/fast-forward')
steps:
- name: Generate access token
uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.LOKSMITH_ID }}
private_key: ${{ secrets.LOCKSMITH_PRIVATE_KEY }}
- name: Fetch repository
uses: actions/checkout@v3
with:
token: ${{ steps.generate-token.outputs.token }}
fetch-depth: 0
- name: Checkout pull request
run: hub pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Fast-forward & push
run: |
export PR_COMMIT=$(git rev-parse HEAD)
git checkout main
git merge --ff-only "$PR_COMMIT"
git push origin main Fast-forward via applying the label `fast-forward`name: Fast-forward
on:
pull_request:
types: [labeled]
jobs:
fast_forward:
name: Fast-forward
runs-on: ubuntu-latest
if: github.event.label.name == 'fast-forward'
steps:
- name: Generate access token
uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.LOKSMITH_ID }}
private_key: ${{ secrets.LOCKSMITH_PRIVATE_KEY }}
- name: Checkout pull request
uses: actions/checkout@v3
with:
token: ${{ steps.generate-token.outputs.token }}
fetch-depth: 0
- name: Fast-forward & push
env:
PR_COMMIT: ${{ github.event.pull_request.head.sha }}
run: |
git checkout main
git merge --ff-only "$PR_COMMIT"
git push origin main That's it! |
Beta Was this translation helpful? Give feedback.
-
It would be really great for GitHub to execute on this feature request. GitHub is nearly 15 years old, and there is still no way for a pull request merge to be fast-forward-only (linear history) AND preserve the same commits as pull request source branch. Today, if you want to preserve commits in your development branch (and not squash them; squashing is great sometimes), you have two bad options
What we need is a fourth option "Fast-forward merge", which requires linear history and only preserves (ie copies) commits from the PR source branch into the target branch. Please, do this. Thanks! |
Beta Was this translation helpful? Give feedback.
-
This is a must feature! |
Beta Was this translation helpful? Give feedback.
-
This feature is a must and can be an advance option and selectable from the dashboard. I’ve been having to —ff-only on my own, as PRs from dev to main in GitHub is a source for headaches. It’s important, make it an experimental feature, let users have linear history please! |
Beta Was this translation helpful? Give feedback.
-
Would be very useful to have this feature! We would use this to power a flow for merging commits from |
Beta Was this translation helpful? Give feedback.
-
I'm about to take my business to a competitor. This is one of the most core parts of an effective git workflow. This needs to be worked on. |
Beta Was this translation helpful? Give feedback.
-
I had absolutely no idea that this was the case for years and I'm actually quite surprised that Github is doing something non-'standard' here. I didn't actually believe it when I first read about it and had to try it myself. Sure enough, Github is performing full replays of history instead of doing fast-forwards, resulting in different commits. My own personal workflow isn't particular impacted by this but thinking back to professional settings this is starting to paint a picture as to why rebases were so inexplicably problematic when people used the Github UI to do them as opposed to on the command line. |
Beta Was this translation helpful? Give feedback.
-
It appears as if I can either
"require linear history" doesn't work either for this purpose. This forces me to merge on the command line (which, by the way, instructions-as-described in enterprise server 3.5 don't actually force a merge commit, but the button does); which I don't know how this plays with "disable pushes to master". I could have sworn that historically there was some kind of option that would perform a ff-merge, perhaps I've gone insane though. I guess I'll have to write a bot / app for our CI for this custom procedure? That feels dumb. |
Beta Was this translation helpful? Give feedback.
-
Generally if there are no conflicts, it is fairly trivial to rebase with
main before commiting, and, in fact, the user interface already supports
doing so automatically.
…On Fri, Jul 14, 2023 at 6:09 AM oakkitten ***@***.***> wrote:
I guess I'll have to write a bot / app for our CI for this custom
procedure? That feels dumb.
Here's my attempt
<#4618 (comment)>
further up.
But I also want to note that if you merely don't have conflicts it doesn't
mean that you can fast forward. To be able to fast-forward, your feature
branch must be based on the last commit of your main branch. Unless you are
willing to update your feature branch every time the main branch is
updated, you can benefit from fast forwarding only when there's very few
people developing very few feature branches on your project.
—
Reply to this email directly, view it on GitHub
<#4618 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANTD3OJECIVUXLNFGE7MDXQELF5ANCNFSM5AI3TFGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
To do the rebase and merge from the command line:
git pull --rebase origin main
git branch -D main
git branch -m main
git push origin main
…On Sat, 15 Jul 2023, 15:30 Chris Copeland, ***@***.***> wrote:
It's mentioned elsewhere in this thread that the rebase merge in the web
UI always rewrites the commits, even if a fast-forward were possible.
—
Reply to this email directly, view it on GitHub
<#4618 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANTD43FZCUFKGWQPXF7O3XQLVTRANCNFSM5AI3TFGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
My comment was more in reference to difficulties if there other commits the
need to be rebased. The ui is able to handle this in the non-fast-forward
case automatically, so it should be no difficulty to do so with fast
forward. My example command was a demonstration that it is trivial to
actually do, as long as there are no conflicts.
…On Sat, 15 Jul 2023, 17:47 Chris Copeland, ***@***.***> wrote:
The command-line workaround has been discussed extensively here and
elsewhere. This thread is a feature request for the GitHub web UI so this
is not required. The situation being described is where the PR is already
fast-forwardable and does not require a rebase. This can be done with one
step:
git push origin origin/<branch>:<base>
—
Reply to this email directly, view it on GitHub
<#4618 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANTDY4VL2N3DWDX22PGE3XQMFY5ANCNFSM5AI3TFGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
I'm saying with little difficulty on THEIR part. The fact that they haven't
done it is the problem, but it is certainly doable
…On Sat, 15 Jul 2023, 18:35 Chris Copeland, ***@***.***> wrote:
Read the rest of the thread for why "it should be no difficulty" is not
accurate. If GitHub's merge-with-rebase option would fast-forward when
possible, it would be a little better, but it doesn't.
—
Reply to this email directly, view it on GitHub
<#4618 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANTDZ54AR25QRLLKYBCXTXQMLMRANCNFSM5AI3TFGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Is there any feedback from Microsoft/Github on this? This is a deal killer for us migrating off of Bitbucket and it is such a fundamental feature of git. |
Beta Was this translation helpful? Give feedback.
-
The last time I talked to an actual github dev was probably 2020 or so, and
I don't think there has been any word from them since then...
…On Wed, 2 Apr 2025 at 11:54, Gordon Cooke ***@***.***> wrote:
Is there any feedback from Microsoft/Github on this? This is a deal killer
for us migrating off of Bitbucket and it is such a fundamental feature of
git.
—
Reply to this email directly, view it on GitHub
<#4618 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANTDZ7BESDTPYIRKGH2C32XQB3ZAVCNFSM5AI3TFG2U5DIOJSWCZC7NNSXTOSENFZWG5LTONUW63SDN5WW2ZLOOQ5TCMRXGAZDSMRU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
There has never been a good reason to NOT do fast-forward merges when it is
possible. The only real reason I have seen for the current behaviour is
that git hashes get regenerated, so some actions get triggered that
wouldn't be, allowing for billing of more computer time...
…On Wed, 2 Apr 2025 at 16:15, Mikko Rantalainen ***@***.***> wrote:
As I see it, somebody trying to send pull request using the GitHub UI
should be the one doing the rebase and GitHub could offer to do this
automatically for them before they submit the pull request. If a merge
could be done without a conflict, the rebase should result in perfectly
identical state but with simpler history.
Rebasing your code to allow fast-forward should be the default and true
merges should be reserved for special cases.
—
Reply to this email directly, view it on GitHub
<#4618 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANTD2TYFRGCAKTAU5CYTD2XRAMLAVCNFSM5AI3TFG2U5DIOJSWCZC7NNSXTOSENFZWG5LTONUW63SDN5WW2ZLOOQ5TCMRXGA3DAOJT>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I would love if a maintainer could please comment on whether or not they are looking into fixing this issue or not in the future. Or if you want to do it but don't have the time currently. |
Beta Was this translation helpful? Give feedback.
-
Why do I land here in 2025, it's crazy |
Beta Was this translation helpful? Give feedback.
-
+10000000000000000000000000000000000000000000000 |
Beta Was this translation helpful? Give feedback.
-
I'm wondering how many years are necessary to implement this. |
Beta Was this translation helpful? Give feedback.
-
We now have agent coding inside Github... But still have no way to merge a branch into master, and have them maintain the same linear history. (Without an external action) |
Beta Was this translation helpful? Give feedback.
-
Oh GitHub, really? 🥴 I mean... REALLY? 😮 If I'd been sitting on a chair, now would be the moment to fall from it... |
Beta Was this translation helpful? Give feedback.
-
Switched from GitLab to GItHub and was absolutely shocked that this is not an option. BitBucket supports -ff merges in PRs as well. Wild to see people discussing this issue years ago and have no resolution or even news. |
Beta Was this translation helpful? Give feedback.
-
For those who really need this feature, Gitea or one of its forks may be worth considering. I have found it to be nearly a drop-in replacement for GitHub, with some nice additional features, including this one. It's free and open source. |
Beta Was this translation helpful? Give feedback.
-
Just switched from Bitbucket and took this possibility for granted. Please include it. |
Beta Was this translation helpful? Give feedback.
-
I was wondering why every time I synced main with the release branch I got this weird branch divergence behavior.... |
Beta Was this translation helpful? Give feedback.
-
I was having some success at getting their attention by working for a very large company who pays them a LOT of money, but then they laid off everybody who was working on this |
Beta Was this translation helpful? Give feedback.
-
plus one to this issue. absolutely unbelievable. please github please. i've worked so hard on my github repo configuration don't make me migrate back to gitlab |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Right now, the only way there is for --ff merges is to use the "Rebase and merge" method. However there's something not optimal with this method. Assuming a feature branch has the following history:
The issue is that when we reference some other commits hashes that might be present on the feature branch, those hashes won't match anymore the commit after the rebase. Thus, in the master branch the git history won't be really optimal. If we have an option to only allow merges of PRs with --ff, we will keep the commit hashes while not having a new merge commit.
note: I do not want to start a discussion about having merge commits or not (some people like it some don't).
Beta Was this translation helpful? Give feedback.
All reactions