Feature Request: Only allow for --ff merges for PRs #4618
Replies: 75 comments 57 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.
-
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 certainly a strange omission but nothing prevents git checkout pr-target
git merge pr-source --ff-only
git push one of the tools suggested in https://github.com/orgs/community/discussions/4618#discussioncomment-1395510 merge_method: fast-forward If you are concerned about how the UI will respond Indeed, the PR UI will respond appropriately closing the PR associated to the pr-source branch that is successfully fast-forward merged into the pr-target branch and pushed from the CLI. Perhaps this is obvious, but I wonder if some potentially large fraction of those concerned about the topic of this thread are primarily concerned that the UI will not respond automatically and appropriately to the equivalent CLI commands. Happy fast-forwarding! |
Beta Was this translation helpful? Give feedback.
-
When will GitHub reach feature parity with Bitbucket from 2018? |
Beta Was this translation helpful? Give feedback.
-
Adding to the pile here... doesn't make sense to repeat what others have already said. So I would just like to ask github product management: please add this. |
Beta Was this translation helpful? Give feedback.
-
As long as real fast forward merges are not supported, GitHub is just a copy of my repository and I make zero changes to the repository with any GitHub provided tools. I make all changes locally and only push results to GitHub. I wish I could do with GitHub provided tools but fast forward merges are mandatory baseline before other tools can be used. |
Beta Was this translation helpful? Give feedback.
-
Please add 🥺 |
Beta Was this translation helpful? Give feedback.
-
did github recently switch silently to do a fast forward merge if possible when you squash a pr? because recently i noticed i can squash a pr and it does not create a merge commit, for whatever reason. |
Beta Was this translation helpful? Give feedback.
-
if you check the co. mit has he's, before and after the merge, they have
changed. Which is totally unnecessary and breaks many things
…On Fri, 4 Oct 2024, 15:39 Alec Kloss, ***@***.***> wrote:
I just tried a squash merge... still sqashes, no fast-forward:
% git show origin/test-main
commit 4ba75f8979b9781761764258a2d39d094e509406 (origin/test-main)
Author: Alec Kloss ***@***.***>
Date: Fri Oct 4 14:36:55 2024 -0500
test (#1783)
% git show test-topic
commit 9d356a27684d9372a4d0f893ee4d21b1a43829e7 (HEAD -> test-topic, origin/test-topic)
Author: Alec Kloss ***@***.***>
Date: Fri Oct 4 14:35:50 2024 -0500
test
% git diff test-topic..origin/test-main
%
I think the log message makes it pretty obvious it's a new commit.
—
Reply to this email directly, view it on GitHub
<#4618 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANTDYIIAW2EXEL5A7TFHTZZ3VHVAVCNFSM5AI3TFG2U5DIOJSWCZC7NNSXTOSENFZWG5LTONUW63SDN5WW2ZLOOQ5TCMBYGQ4DAOJT>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
looking forward to fastward feature |
Beta Was this translation helpful? Give feedback.
-
Shocking that Github does not have this feature. This is a clear selling point for Gitlab/Bitbucket. |
Beta Was this translation helpful? Give feedback.
-
Elias, the difference between fast-forward and squash is with fast-forward,
the head of the destination branch is moved to point to the head of the
source branch. With squash, all of the commits in the source branch are
squashed down to one commit, and that commit is applied to the head of the
destination branch. I normally do both, where I squash the source branch,
and then fast-forward merge it to the destination. The main visible
difference between doing it my way, and just squashing, is that with fast
forward, the commit hashes are the same on both branches at the end, which
helps eliminate extra builds by the CI system
…On Wed, 9 Oct 2024 at 03:59, Elias Rami ***@***.***> wrote:
but still there are no merge commits anymore with squash, which is
normally what fast forward does? i'm 100% sure there where merge commits
with squash a few months before.
—
Reply to this email directly, view it on GitHub
<#4618 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANTDZA7IZ5INLGRS7IFEDZ2TO7RAVCNFSM5AI3TFG2U5DIOJSWCZC7NNSXTOSENFZWG5LTONUW63SDN5WW2ZLOOQ5TCMBYHA4TCNJW>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
It's kinda crazy that this option isn't available. I wonder why? I don't see any downsides of allowing users to fast-forward. |
Beta Was this translation helpful? Give feedback.
-
This is related to https://github.com/orgs/community/discussions/8940 |
Beta Was this translation helpful? Give feedback.
-
This is a very useful and basic functionality of Git. What blocks its implementation? |
Beta Was this translation helpful? Give feedback.
-
How is this not supported yet? Please add this. |
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