Feature Request: Only allow for --ff merges for PRs #4618
Replies: 127 comments 121 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. |
|
Related: (Kudos to my colleague, @lekob, who collected these.) |
|
The issue title is a bit weird. To me a good idea would be like this:
|
|
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 mainFast-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 mainThat's it! |
|
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! |
|
This is a must feature! |
|
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! |
|
Would be very useful to have this feature! We would use this to power a flow for merging commits from |
|
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. |
|
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. |
|
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. |
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
I don't understand why this hasn't been implemented yet. Why should we need to do all these kind of workarounds for a simple thing that is already possible on the CLI? This feature needs to be added. |
|
What a mess! We ended up designing a completely different process, with no Pull Requests and no Peer Reviews. Based on a classic Open Source contribution workflow with the 👀👀-principle is based on paired programming and mob programming. I've covered it in a blog post all the tools; a GitHub CLI extension and a handfull of generic callable workflows we developed are open source. |
|
+1 to adding this. I'm shocked there's features ADO supports that Github doesn't. |
|
+1 |
|
There is no way this issue still needs bumping and there is not even a single official mention of resolving it.... but sure go ahead add another shitty ai slop to the platform! |
|
The fact that so many people suggest workarounds drives me even more crazy. The kindness and willingness to solve our own problem as well as others is the heart of this platform. Come on. Life is hard enough to have to fight with the number 1 platform that host OSS for such minor feature request. |
|
I just made a somewhat feeble attempt to help this go viral... https://www.linkedin.com/posts/craig-west-a3b1aa3_feature-request-only-allow-for-ff-merges-activity-7404546223610949632-oMDk |
|
All I can say is that you can tell Microsoft own Github now - and by that I mean: they don't give two hoots about the people that use the product... Market share is their only metric for concern. |
|
+1 - again, this is needed. |
|
2026 is here, still need to fast forward manually... |
|
I'm flabbergasted Github.com... |
|
I developed a Chrome extension that solves this problem. Give it a try!! → https://github.com/simnalamburt/ff-for-github
|
|
So is github going to allow this or not? |
|
yes plz |
No, at least not in the foreseeable future, unless there are major organizational changes. Given everything that has happened (and is still happening) with GitHub over the last few weeks, they first need to figure out how to handle basic Git functions properly while keeping the cumulative uptime of their services above 90% (https://mrshu.github.io/github-statuses/). The fiasco with merge queues rewriting history a few weeks ago suggests that internal PR operations may be far more chaotic than most of us assume, and why such functionality may be much harder to implement for them (although I don't buy this as a reason). I suggest that we keep posting only our custom solutions here (and discussing them in a thread, example above: https://github.com/orgs/community/discussions/4618#discussioncomment-16396715), instead of repeatedly asking for updates from their side - there will be none, they have much larger issues to fix. |

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).
All reactions