git/list[1] front-page[2] threads[3] people[4] search[5] about
 

reject "backwards" merges

From
PDPatrick Donnelly <batrick@batbytes.com>
Date
Dec 12, 2014, 18:40 UTC
Message-ID
<CACh33FqHindeksHv7wcgu983oBSbm5G0ZswrQdTAz5tqgZdgjQ@mail.gmail.com>

Is there a way to reject pushes that change the history of first-parents, caused by a "backwards" merge? To clarify by example (using branches instead of separate repositories):

$ git init
Initialized empty Git repository in /tmp/tmp.O0efpRrV4p/.git/
$ touch foo
$ git add foo
$ git commit -m initial
[master (root-commit) c4890b9] initial
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo
$ git branch b1
$ touch bar
$ git add bar
$ git commit -m bar
[master 9cb303e] bar
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 bar
$ git checkout b1
Switched to branch 'b1'
$ touch baz
$ git add baz
$ git commit -m baz
[b1 4c618bc] baz
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 baz
$ git merge master
Merge made by the 'recursive' strategy.
 bar | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 bar
$ git checkout master
Switched to branch 'master'
$ git merge b1
Updating 9cb303e..1b0a9d4
Fast-forward
 baz | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 baz
$ git log --graph
*   commit 1b0a9d4a011cd7e36c8c58b190aed0b450f06ca1
|\  Merge: 4c618bc 9cb303e
| | Author: Patrick Donnelly <>
| | Date:   Fri Dec 12 13:32:51 2014 -0500
| |
| |     Merge branch 'master' into b1
| |
| * commit 9cb303e2578af305d688abf62570ef31f3f113da
| | Author: Patrick Donnelly <>
| | Date:   Fri Dec 12 13:32:23 2014 -0500
| |
| |     bar
| |
* | commit 4c618bc094e82d9a5126a1c3fbc59921e41bd7b5
|/  Author: Patrick Donnelly <>
|   Date:   Fri Dec 12 13:32:46 2014 -0500
|
|       baz
|
* commit c4890b9bd590b34a9eb955d50e6e736729509a7c
  Author: Patrick Donnelly <>
  Date:   Fri Dec 12 13:31:46 2014 -0500
      initial

Here the desired first parent (HEAD^) would be commit 9cb303e2578af305d688abf62570ef31f3f113da. Unfortunately, the incorrect merge reversed the line of parents. Is there a way to prevent this from happening (via git-config) other than fixing the human?

-- 
Patrick Donnelly
Next: David Kastrup
Message 1 of 2 in “reject "backwards" merges”
  1. Patrick DonnellyDec 12, 2014
  2. David KastrupDec 13, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.