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

Git pull --rebase with strategy ours doesn't work (possibly bug)

From
Dmitry S. Kravtsov <idkravitz@gmail.com>
Date
Jun 13, 2011, 03:05 UTC
Message-ID
<BANLkTi=jLQf6Wp-qqYoy7kND2M1=WRyxXg@mail.gmail.com>
Hi,
So here the steps to reproduce:
$ git init A
Initialized empty Git repository in /home/catsadmin/git-test/A/.git/
$ (cd A && echo 123 > file && git add file && git commit -m "1st")
[master (root-commit) 1055edf] 1st
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 file
$ git clone A B
Cloning into B...
done.
$ git clone A C
Cloning into C...
done.
$ (cd B && echo 333 >file && git commit -am "2nd")
[master 4e9cd67] 2nd
 1 files changed, 1 insertions(+), 1 deletions(-)
$ (cd A && git pull ~/git-test/B master)
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /home/catsadmin/git-test/B
 * branch            master     -> FETCH_HEAD
Updating 1055edf..4e9cd67
Fast-forward
 file |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
$ (cd C && echo 111 > file && git commit -am "3rd")
[master 1c4a368] 3rd
 1 files changed, 1 insertions(+), 1 deletions(-)
$ cd C
$ git push origin master
To /home/catsadmin/git-test/A
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '/home/catsadmin/git-test/A'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

So my idea is to create a straight line history, that will look like "1st"---"2nd"---"3rd", and from git-rebase man page I read, that strategy ours allows us to discard conflicing changes in favor of ours.

$ git pull --rebase -s ours origin master
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /home/catsadmin/git-test/A
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Already applied: 0001 3rd
/usr/bin/git-rebase: line 157:
/home/catsadmin/git-test/C/.git/rebase-merge/rewritten: Нет такого
файла или каталога
All done.
This message not only looks weird, it also discard my "3rd" commit
from master tree:
$ git branch
* master
$ git log
commit 4e9cd6730b1215b22b65fbcc6cbf87e331e5eb92
Author: Your Name <you@example.com>
Date:   Mon Jun 13 13:53:27 2011 +1100
    2nd
commit 1055edf3618787ea53231ed6f4b00dfe571c8940
Author: Your Name <you@example.com>
Date:   Mon Jun 13 13:52:53 2011 +1100
    1st
Am I wrong at something?
-- 
Dmitry S. Kravtsov
Next: Dmitry S. Kravtsov
Message 1 of 5 in “Git pull --rebase with strategy ours doesn't work (possibly bug)”
  1. Dmitry S. KravtsovJun 13, 2011
  2. Dmitry S. KravtsovJun 13, 2011
  3. Dmitry S. KravtsovJun 13, 2011
  4. Dmitry S. KravtsovJun 13, 2011
  5. Junio C HamanoJun 13, 2011

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.