Feature Request: Only allow for --ff merges for PRs #4618
Replies: 53 comments 42 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.
-
This is one thing that makes me look for alternatives to GitHub. Although I do like the service a lot, this is such a strategic feature, as explained by the other comments, that at first, I didn't believe GitHub did not have this option, so I had to try it for myself, and none of the merge strategies do that. |
Beta Was this translation helpful? Give feedback.
-
Adding my voice to the pile 😄 this is one of the things that's potentially stopping us from migrating from BitBucket which has this feature. |
Beta Was this translation helpful? Give feedback.
-
It's crazy how GitHub doesn't support this. |
Beta Was this translation helpful? Give feedback.
-
I was surprised when realized github doesn't support --ff. Outdated bitbucket allowed us to have linear history and avoid all these problems with signed commits, inability to delete all merged local branches, etc it seems to be easier to use another tool than get this feature :) |
Beta Was this translation helpful? Give feedback.
-
In case anyone is still having issues with the lack of -ff merges, this may help: Protected GitHub fast-forward commit action with Mergefreeze [Github Gist]. This is not an ideal solution, and it will cost your organization an additional $40/month, but it works well. We spent a lot of time figuring it out. Mergefreeze, combined with the action, prevents you from accidentally merging via the default web UI options by blocking them using a branch protection rule. The When run by adding a CC @giovannicandido / @izaakschroeder / @davidreis97 / @alexeymenkov / @jraczykowski / @d81853embitel-de / @ryanberckmans / @Fab1n / @mauricioklein in particular, as you all seem to have experienced this issue recently 🙏 . |
Beta Was this translation helpful? Give feedback.
-
I love the idea and hope you have great success with it but I'll avoid the
extra dependency and complexity and just disable rebasing as a merge
strategy, at the cost of not having a linear history.
…On Tue, 16 Jan 2024 at 02:38, Sebastian Mellen ***@***.***> wrote:
In case anyone is still having issues with the lack of -ff merges, this
may help: Protected GitHub fast-forward commit action with Mergefreeze
[Github Gist]
<https://gist.github.com/sebmellen/639904445118be908cbe3c23d9797d46>.
This is not an ideal solution, and it will cost your organization an
additional $40/month, but it works well. We spent a lot of time figuring it
out. Mergefreeze, combined with the action, prevents you from accidentally
merging via the default web UI options by blocking them using a branch
protection rule. The fast-forward action blocks all commits to your
desired branch that don't use the action.
When run by adding a /fast-forward comment to your PR, the action
temporarily suspends the required Mergefreeze branch protection rule,
merges the commit to your desired branch through the CLI, and then adds
back the branch protection rule. This avoids any mistaken merge/rebase
commits, and it works just as fast as merging using the traditional web UI
options.
CC @giovannicandido <https://github.com/giovannicandido> / @izaakschroeder
<https://github.com/izaakschroeder> / @davidreis97
<https://github.com/davidreis97> / @alexeymenkov
<https://github.com/alexeymenkov> / @jraczykowski
<https://github.com/jraczykowski> / @d81853embitel-de
<https://github.com/d81853embitel-de> in particular, as you all seem to
have experienced this issue recently 🙏 .
—
Reply to this email directly, view it on GitHub
<#4618 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADXDBG5CINSPKTUI5C6E74DYOXRZ5AVCNFSM5AI3TFG2U5DIOJSWCZC7NNSXTOKENFZWG5LTONUW63SDN5WW2ZLOOQ5TQMJTHEYTONQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Please add an option to only allow ff merges! |
Beta Was this translation helpful? Give feedback.
-
This would simplify our workflow, we have a production branch that is protected so we can pass SOC2 checks. We have to open a PR from main to prod, even after the PRs have already been merged into main where we ensure that no PRs can be merged without approval etc. Having an option to allow FF from specific branches would be great for us. |
Beta Was this translation helpful? Give feedback.
-
Gitea will support this with the next release. See go-gitea/gitea#28954 |
Beta Was this translation helpful? Give feedback.
-
Please add this! |
Beta Was this translation helpful? Give feedback.
-
it is absolutly insane that this is missing just to quote a stackoverflowman which represents my opinion |
Beta Was this translation helpful? Give feedback.
-
We also need this please! |
Beta Was this translation helpful? Give feedback.
-
I've found that this GitHub action works: https://github.com/marketplace/actions/fast-forward-merge and preserves commit signatures. Consider adding an alias for gh alias set submit 'pr comment --body "/fast-forward"' Use a rebase-based workflow with this. Submit your PR from the command line: gh submit |
Beta Was this translation helpful? Give feedback.
-
Please add this! |
Beta Was this translation helpful? Give feedback.
-
Another reason to do this: GitHub is wasting a lot of compute on redundant workflow runs for rebased commits that could have been fast-forwarded. |
Beta Was this translation helpful? Give feedback.
-
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