> Am 23.02.2018 um 00:20 schrieb Jonathan Nieder <[email protected]>:
>
> Hi Marcel,
>
> …
> Sorry, this is not the most helpful reply but:
>
> Can you describe a reproduction recipe so that I can experience the
> same thing?
>
> That is:
>
> 1. steps to reproduce
> 2. expected result
> 3. actual result
> 4. the difference and why it was unexpected
>
1. steps to reproduce
=====================
```
Last login: Fri Feb 23 00:33:11 on ttys001
~ PATH variable not enhanced, no applications found in ~/Applications/*-latest
-bash:/Users/marcel:$ mkdir /tmp/$$
change to new directory '/tmp/2608'? [Y/n]
-bash:/tmp/2608:$ mkdir a.git
change to new directory 'a.git'? [Y/n]
-bash:/tmp/2608/a.git:$ git init
Initialized empty Git repository in /private/tmp/2608/a.git/.git/
-bash:/tmp/2608/a.git:$ touch foo
-bash:/tmp/2608/a.git:$ git add foo
-bash:/tmp/2608/a.git:$ git commit -m "foo" foo
[master (root-commit) ed191c4] foo
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 foo
-bash:/tmp/2608/a.git:$ cd -
/tmp/2608
-bash:/tmp/2608:$ mkdir b.git
change to new directory 'b.git'? [Y/n]
-bash:/tmp/2608/b.git:$ git init
Initialized empty Git repository in /private/tmp/2608/b.git/.git/
-bash:/tmp/2608/b.git:$ touch bar
-bash:/tmp/2608/b.git:$ git add bar
-bash:/tmp/2608/b.git:$ git commit -m "bar" bar
[master (root-commit) 80b0355] bar
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 bar
-bash:/tmp/2608/b.git:$ cd -
/tmp/2608
-bash:/tmp/2608:$ git clone a.git c
Cloning into 'c'...
done.
-bash:/tmp/2608:$ cd c
-bash:/tmp/2608/c:$ ll
total 0
drwxr-xr-x 12 marcel wheel 384B 23 Feb 05:47 .git
-rw-r--r-- 1 marcel wheel 0B 23 Feb 05:47 foo
-bash:/tmp/2608/c:$ git pull ../b.git/
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../b
* branch HEAD -> FETCH_HEAD
Successfully rebased and updated refs/heads/master.
-bash:/tmp/2608/c:$ ll
total 0
drwxr-xr-x 14 marcel wheel 448B 23 Feb 05:47 .git
-rw-r--r-- 1 marcel wheel 0B 23 Feb 05:47 bar
-bash:/tmp/2608/c:$ git reflog
80b0355 (HEAD -> master) HEAD@{0}: pull ../b.git/: checkout
80b03552466bc526b1130ce5ca4a991ba31a0546: returning to refs/heads/master
80b0355 (HEAD -> master) HEAD@{1}: pull ../b.git/: checkout
80b03552466bc526b1130ce5ca4a991ba31a0546
ed191c4 (origin/master, origin/HEAD) HEAD@{2}: clone: from /tmp/2608/a.git
-bash:/tmp/2608/c:$ git remote -v
origin /tmp/2608/a.git (fetch)
origin /tmp/2608/a.git (push)
-bash:/tmp/2608/c:$ git log --all --graph --decorate --oneline
--simplify-by-decoration
* 80b0355 (HEAD -> master) bar
* ed191c4 (origin/master, origin/HEAD) foo
```
2. expected result
==================
just an error in case the too trees have no common ancestors
```
-bash:/tmp/2608/c:$ git pull ../b.git/
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../b
* branch HEAD -> FETCH_HEAD
fatal: refusing to merge unrelated histories
```
3. actual result
================
pulls out, removes all files from the first tree
4. the difference and why it was unexpected
===========================================
I can’t find words on it … it should not work but it did? somehow … with
unexpected results to my local repository
it somehow seems to be an issue of my config, because resetting it, will not
allow the pull as expected
```
-bash:/tmp/2608/c:$ GIT_CONFIG_NOSYSTEM=1 HOME=. git config -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=/tmp/2608/a.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
-bash:/tmp/2608/c:$ GIT_CONFIG_NOSYSTEM=1 HOME=. git pull ../b.git/
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../b
* branch HEAD -> FETCH_HEAD
fatal: refusing to merge unrelated histories
-bash:/tmp/2608/c:$ git pull ../b.git/
From ../b
* branch HEAD -> FETCH_HEAD
Successfully rebased and updated refs/heads/master.
```
the logs tells me he rebases ...
```
-bash:/tmp/2608/c:$ git config -l | grep merge
diff.tool=p4merge
merge.tool=p4merge
merge.branchdesc=true
merge.log=true
branch.autosetupmerge=true
branch.master.merge=refs/heads/master
-bash:/tmp/2608/c:$ git config -l | grep pull
pull.rebase=preserve
-bash:/tmp/2608/c:$ git config -l | grep fetch
fetch.recursesubmodules=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
```
> I suspect that this information is in your message, somewhere, but it
> is (understandably) unfocussed and I am having trouble pulling it out.
>
I’m sorry, I just wanted to write down first any helpful information without -
being late - having time to go into further investigations myself … hopefully
to get some answers that „this is ok, you’re just stupid and didn’t read the
spec/doc“ or „ok, this seems strange to me too, can we go forward in details
and analysis“ ;)
> [...]
>> trying to fix this up by doing another pull failed:
>> ```
>> -bash:$ git remote -v
>> origin [email protected]:childnode/marcel.git (fetch)
>> origin [email protected]:childnode/marcel.git (push)
>>
>> -bash:$ git pull
>> fatal: refusing to merge unrelated histories
>
> Ok, this part is something I might be able to help shed some light on.
>
> Searching for 'unrelated' in "git help pull" finds:
>
> --allow-unrelated-histories
> By default, git merge command refuses to merge histories that do not
> share a common ancestor. This option can be used to override this
> safety when merging histories of two projects that started their
> lives independently. As that is a very rare occasion, no
> configuration variable to enable this by default exists and will not
> be added.
>
> So that explains the "what" of that error message.
>
> The "why" is a separate question. Could you share output from
>
> git log --all --graph --decorate --oneline --simplify-by-decoration
>
> and
>
> git status
>
```
-bash:/tmp/2608/c:$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
-bash:/tmp/2608/c:$ git branch -avv
* master 80b0355 [origin/master: ahead 1, behind 1] bar
remotes/origin/HEAD -> origin/master
remotes/origin/master ed191c4 foo
```
> to help us understand your current state?
>
> Also, suggestions for improvements to the 'refusing to merge' message
> would be very welcome.
>
> Thanks and hope that helps,
> Jonathan
just to say: the latter „refused pull“ is what I expect the first time too!
SUSPECTED / PROVEN to found a guilty setting
=============================================
```
-bash:/tmp/2608/c:$ GIT_CONFIG_NOSYSTEM=1 HOME=. git -c user.name="me" -c
[email protected] pull -r ../b.git/
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../b
* branch HEAD -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: foo
-bash:/tmp/2608/c:$ ll
total 0
drwxr-xr-x 14 marcel wheel 448B 23 Feb 06:21 .git
-rw-r--r-- 1 marcel wheel 0B 23 Feb 06:21 bar
-rw-r--r-- 1 marcel wheel 0B 23 Feb 06:21 foo
```
shows me a quite different behavior, so solely rebase not seems the full problem
BUT
`--rebase=preserve` will .. o’man , really, is this intended?
Yes, I see, rebase is a harmful operation and yes, you might now tell me a fool
to apply this per default
but why is this unrelated history check different from pull (merge) to rebase
to rebase -p ?
Can’t find a word on it
https://git-scm.com/docs/git-rebase#git-rebase---preserve-merges
With regards,
~Marcel