{"id":19053285,"url":"https://github.com/sbmueller/the-problem-with-merge-commits","last_synced_at":"2025-08-19T21:27:02.486Z","repository":{"id":83263288,"uuid":"594764192","full_name":"sbmueller/the-problem-with-merge-commits","owner":"sbmueller","description":"One reason to avoid merge commits","archived":false,"fork":false,"pushed_at":"2023-01-29T16:05:52.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-14T20:55:08.053Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbmueller.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-29T15:20:19.000Z","updated_at":"2023-01-30T07:23:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"2dacab6f-5dde-459b-8b82-7a4d27468af9","html_url":"https://github.com/sbmueller/the-problem-with-merge-commits","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbmueller%2Fthe-problem-with-merge-commits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbmueller%2Fthe-problem-with-merge-commits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbmueller%2Fthe-problem-with-merge-commits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbmueller%2Fthe-problem-with-merge-commits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbmueller","download_url":"https://codeload.github.com/sbmueller/the-problem-with-merge-commits/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240109716,"owners_count":19749181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T23:29:58.684Z","updated_at":"2025-02-22T01:16:14.557Z","avatar_url":"https://github.com/sbmueller.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Problem with Merge Commits\n\nThis repository serves as a small example that should emphasize one issue with\nmerge commits: A new, unreviewed and untested code state might be automatically\ncreated on the server side.\n\n## Observation\n\nIn this repo, let's assume multiple contributors work on an application. The\ninitial commit `a573d9a` can be seen as an arbitrary long history in this\nrepository, serving as starting point with a passing CI.\nThe next commit `e2d24c7`, introduces an extension to the business logic with a\nfile `main.py` and an extension of the CI to execute this file. Note the CI is\ngreen.\nAnother contributor works on a feature branch `add-config` to add another file\n`foo.cfg` in an unrelated context. This change could be any more complex\nchange, but let's stay with this simple example. See the pull request for this\nfeature in\n[#3](https://github.com/sbmueller/the-problem-with-merge-commits/pull/3). The\nCI is green and the reviewer, not suspecting anything bad, approves the merge.\nLastly, the merge is performed using a **merge commit** `62d49b6`, on `main`\nsuddenly the CI fails. What happened?\n\n## Explanation\n\nThe issue is, that a merge commit introduces a new, unreviewed and untested\ncode state that has not existed before. At no point in time, the files\n`main.py` and `foo.cfg` were simultaneously existing. The first time this\nhappened was after the automatically created merge commit, only on server side.\n\nUnfortunately, the file `foo.cfg` has a \"complex\" interplay with the business\nlogic in `main.py` which could not be observed before.\n\n## How to avoid this\n\nRather than a merge commit, a fast forward merge should be performed:\n\n```\ngit merge [branch] --ff-only\n```\n\nAmong other benefits like a linear history, this avoids unseen code states. If\nthe changes are incompatible for a fast forward, which just means the target\nbranch pointer gets moved to the source branch pointer, an error is displayed,\nasking the user base their changes of the target branch:\n\n```\ngit rebase -i main\n```\n\nAfter this command, no parallel changes will exist like in our example above.\nThe file `main.py` would suddenly exist in the branch `add-config` and the\nfailure would be detected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbmueller%2Fthe-problem-with-merge-commits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbmueller%2Fthe-problem-with-merge-commits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbmueller%2Fthe-problem-with-merge-commits/lists"}