# Git Unrelated Histories

4 messages from 2018-08-29 to 2018-08-29. Participants: Tomas Zubiri, Stefan Beller.
Thread: https://gitlist.dev/t/49252

## Tomas Zubiri, 2018-08-29 16:49

Subject: Git Unrelated Histories
Message-ID: <CAE3VKEp3PJLCy3tL=K51nNzGry-HySb57QHemZzMtg3RkBmzUw@mail.gmail.com>
URL: https://gitlist.dev/e/CAE3VKEp3PJLCy3tL%3DK51nNzGry-HySb57QHemZzMtg3RkBmzUw%40mail.gmail.com

```
Hello all,

I have recently joined a team there seems to be a couple of  issue
with the git repositories:


1- A branch created from development cannot be merged into the
production branch.



(production)

git merge development_feature_branch



fatal: refusing to merge unrelated histories




2- If there is a file that only has a 1 line difference in production,
a git diff will return that the whole file is different:

git diff production:folder development:folder


“
diff --git a/folder/file.py b/folder/file.py

index 9bfd6612..20cce520 100644

--- a/folder/file py

+++ b/folder/file.py

@@ -1,245 +1,245 @@

“

I’m not 100% sure what happened here. But it seems that changes and
added files are copied and pasted into the production branch and
uploaded indepenedently as separate files, contributing to a huge
difference between branches.

How can I confirm this hypothesis, and what steps can I take to solve it?

Thank you.

```

## Stefan Beller, 2018-08-29 18:15

Subject: Re: Git Unrelated Histories
Message-ID: <CAGZ79kakEYc954nQDThAZ0fSwbNp2-GGwthnevoQ4DxEUu4gZA@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kakEYc954nQDThAZ0fSwbNp2-GGwthnevoQ4DxEUu4gZA%40mail.gmail.com
In-Reply-To: <CAE3VKEp3PJLCy3tL=K51nNzGry-HySb57QHemZzMtg3RkBmzUw@mail.gmail.com>

```
On Wed, Aug 29, 2018 at 9:49 AM Tomas Zubiri <me@tomaszubiri.com> wrote:
>
> Hello all,
>
> I have recently joined a team there seems to be a couple of  issue
> with the git repositories:
>
>
> 1- A branch created from development cannot be merged into the
> production branch.
>
>
>
> (production)
>
> git merge development_feature_branch
>
>
>
> fatal: refusing to merge unrelated histories
>

See the git merge man page for the
  --allow-unrelated-histories switch.

>
>
>
> 2- If there is a file that only has a 1 line difference in production,
> a git diff will return that the whole file is different:
>
> git diff production:folder development:folder
>
>
> “
> diff --git a/folder/file.py b/folder/file.py
>
> index 9bfd6612..20cce520 100644
>
> --- a/folder/file py
>
> +++ b/folder/file.py
>
> @@ -1,245 +1,245 @@
>
> “
>
> I’m not 100% sure what happened here. But it seems that changes and
> added files are copied and pasted into the production branch and
> uploaded indepenedently as separate files, contributing to a huge
> difference between branches.

It sounds to me as if there would be line ending issues or some sort
of whitespace issues (tab vs spaces).

>
> How can I confirm this hypothesis, and what steps can I take to solve it?

git diff --ignore-all-space
or --ignore-space-at-eol

Look at gitattributes to set your flavor for files so you don't have
to pass these flags all the time

Stefan

```

## Tomas Zubiri, 2018-08-29 20:18

Subject: Fwd: Git Unrelated Histories
Message-ID: <CAE3VKErVQ9-PcQ-83xUqBDvLxNUDmWvhOAm4SMhqpQyAZCWQEg@mail.gmail.com>
URL: https://gitlist.dev/e/CAE3VKErVQ9-PcQ-83xUqBDvLxNUDmWvhOAm4SMhqpQyAZCWQEg%40mail.gmail.com
In-Reply-To: <CAE3VKErGMSgB9gJAEnAuEDE51Yem6WUsg6fmOQELY1HCrALk_Q@mail.gmail.com>

```
Thank you for taking the time to help me Stefan


On Aug 29, 2018 15:15, "Stefan Beller" <sbeller@google.com> wrote:
>
> On Wed, Aug 29, 2018 at 9:49 AM Tomas Zubiri <me@tomaszubiri.com> wrote:
> >
> > Hello all,
> >
> > I have recently joined a team there seems to be a couple of  issue
> > with the git repositories:
> >
> >
> > 1- A branch created from development cannot be merged into the
> > production branch.
> >
> >
> >
> > (production)
> >
> > git merge development_feature_branch
> >
> >
> >
> > fatal: refusing to merge unrelated histories
> >
>
> See the git merge man page for the
>   --allow-unrelated-histories switch.

I have tried that switch, however when merging a small feature branch,
the merge tries to merge ALL of the differences between both branches,
and they have diverged quite a long while ago.
I am not getting the expected behaviour of just merging the changes
from the feature branch.

git-merge-base shows a common ancestor from 2 months ago,  btw.


>
> >
> >
> >
> > 2- If there is a file that only has a 1 line difference in production,
> > a git diff will return that the whole file is different:
> >
> > git diff production:folder development:folder
> >
> >
> > “
> > diff --git a/folder/file.py b/folder/file.py
> >
> > index 9bfd6612..20cce520 100644
> >
> > --- a/folder/file py
> >
> > +++ b/folder/file.py
> >
> > @@ -1,245 +1,245 @@
> >
> > “
> >
> > I’m not 100% sure what happened here. But it seems that changes and
> > added files are copied and pasted into the production branch and
> > uploaded indepenedently as separate files, contributing to a huge
> > difference between branches.
>
> It sounds to me as if there would be line ending issues or some sort
> of whitespace issues (tab vs spaces).
>
> >
> > How can I confirm this hypothesis, and what steps can I take to solve it?
>
> git diff --ignore-all-space
> or --ignore-space-at-eol

This worked. Thank you!

>
> Look at gitattributes to set your flavor for files so you don't have
> to pass these flags all the time
>
> Stefan

```

## Stefan Beller, 2018-08-29 20:13

Subject: Re: Git Unrelated Histories
Message-ID: <CAGZ79kZ1fcvBbJ9K+jw=wvCseSURSEKvnCDNFGsuZqcOfcZ7tQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kZ1fcvBbJ9K%2Bjw%3DwvCseSURSEKvnCDNFGsuZqcOfcZ7tQ%40mail.gmail.com
In-Reply-To: <CAE3VKErGMSgB9gJAEnAuEDE51Yem6WUsg6fmOQELY1HCrALk_Q@mail.gmail.com>

```
+cc the mailing list

> > >
> > > git merge development_feature_branch
> > > fatal: refusing to merge unrelated histories
> > >
> >
> > See the git merge man page for the
> >   --allow-unrelated-histories switch.
>
> I have tried that switch, however when merging a small feature branch,
> the merge tries to merge ALL of the differences between both branches,
> and they have diverged quite a long while ago.
> I am not getting the expected behaviour of just merging the changes
> from the feature branch.
>
> git-merge-base shows a common ancestor from 2 months ago,  btw.
>

```
