Re: Merging two Git-Repositories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/17/19 10:28 AM, Steve Keller wrote:
> Is it possible to merge one Git-Repository into another?  I have
> developed two independent repositories A and B, and now I find that
> B should be part of A in new sub-directory, e.g. A/B.  I want to
> move B into A while keeping the whole development history of B.

If I get you right, you want a simple merge of two branches with no
common ancestors. Here's a line-by-line sh example with project A in
directory A and project B in directory B, and B will be merged into a
subdirectory "project-b" in A:

  # change to B's directory
  cd B

  # create the subdirectory where B's files will be in A
  mkdir project-b

  # move all files into project-b
  git mv -k * project-b

  # probably check if this worked for you
  ls
  git status

  # commit
  git commit -m "Move all files into subdirectory for inclusion into A"

  # change to A's directory
  cd ../A

  # fetch and merge B into A
  git pull --no-rebase --allow-unrelated-histories ../B
  # ... change commit message to something more meaningful ...

That's it.

If B is public you might want to replace its last commit by some commit
that adds a note that further development is going on in A.

Stephan



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux