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

Bug report: 'git rebase' confusing files with initially equal content

From
BGBernhard Graf <gitml@augensalat.de>
Date
Jul 14, 2016, 14:11 UTC
Message-ID
<d105b779-7eb7-845f-d503-263846919c1a@augensalat.de>

With the following steps content from one file ends up in another file by using 'git rebase' (and clobbers the original content). It is rather straight forward and I discovered this behaviour when trying to replay http://gitforteams.com/resources/rebasing.html . The special thing is, that both files have the same content at start.

   $ mkdir rebase
   $ cd rebase
   git --version
   git version 2.9.0
   $ git init
   Initialized empty Git repository in /home/graf/projects/git/rebase/.git/
   $ echo stub >file1
   $ echo stub >file2
   $ git add .
   $ git commit -m 'add stub'
   [master (root-commit) 0cb53e9] Add stubs
    2 files changed, 2 insertions(+)
    create mode 100644 file1
    create mode 100644 file2
   $ git checkout -b feature/1
   Switched to a new branch 'feature/1'
   $ echo line1 >file1
   $ git commit -am 'Add content'
   [feature/1 2f3dcc7] Add content
    1 file changed, 1 insertion(+), 1 deletion(-)
   $ git checkout master
   Switched to branch 'master'
   $ git rm file1
   rm 'file1'
   $ git commit -m 'Delete file1'
   [master 1b18590] Delete file1
    1 file changed, 1 deletion(-)
    delete mode 100644 file1
   $ git checkout feature/1
   Switched to branch 'feature/1'
   $ echo line2 >>file1
   $ git commit -am 'Add more content'
   [feature/1 36be376] Add more content
    1 file changed, 1 insertion(+)
   $ cat file1
   line1
   line2
   $ cat file2
   stub
   $ git rebase master
   First, rewinding head to replay your work on top of it...
   Applying  Add content
   Using index info to reconstruct a base tree...
   A	file1
   Falling back to patching base and 3-way merge...
   Auto-merging file2
   Applying  Add more content
   Using index info to reconstruct a base tree...
   A	file1
   Falling back to patching base and 3-way merge...
   Auto-merging file2
   $ ls -l
   total 8
   -rw-r--r--  1 graf  users  12 14 Jul 13:16 file2
   $ cat file2
   line1
   line2

If instead file1 and file2 initially had different contents, 'git rebase' runs into a merge conflict, so the user can fix it appropriatly.

I suppose this is related to the fact that Git manages the repo by file contents only. Still this is nothing what I would expect (and neither accept).

-- 
Bernhard Graf
Message 1 of 1 in “Bug report: 'git rebase' confusing files with initially equal content”
  1. Bernhard GrafJul 14, 2016

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.