this post was submitted on 06 Oct 2025
828 points (96.7% liked)
Programmer Humor
26799 readers
2028 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
On some repositories, sure.
But better maintained repositories don't allow merge commits (because merge commits suck), and so will have squashed (or rebased) on merge.
(If squashed) The squash will have changed commit IDs, so a long running branch rebased won't benefit from a clean shared commit history.
So it can work, but "you're gonna have a bad time."
In general, git works best if branches are thrown away as soon and as often as possible.
(Edit: Good clarification in response below, added here for consistency and accuracy.)
You don't have to squash to avoid merge commits. Instead, you can
git rebase main
to update your branch. Effectively, this will rewrite the history of your branch, as if you had just branched from the main-branch and then instantly coded all your changes on top of that. (Well, the commit timestamps won't change, but they will sit on top of the changes of the main-branch.)Afterwards, you should be able to merge into
main
by switching to it and then runninggit merge --ff-only your_branch
.Because all the changes sit on top of the main-branch commits, it should be able to fast-forward. No actual merging needs to take place then. You've already resolved any conflicts while rebasing.
This also allows you to keep branches for longer, so long as you frequently rebase and merge back.