GIT - "import" content from another repo to a branch

3

My question is:

I have a repository called "site-layout" with only the branch master, where I develop a layout with the bootstrap v4.

I still own another repository called "site-old" also only with the branch master, where is the code of another layout but created with the bootstrap v3.

What I would like to do is to "import" (I do not know if that would be the correct term) this "site-old" into the "site-layout" as a new branch that I want to call "bootstrapv3" ( and then delete the "site-old", and then, if possible, "mirror" this branch in the site-layout master.

EDIT: If it gets too complicated (even better), it could just be "mirror" the content of the "old site" directly in the site-layout master, as long as it does not interfere with the fork I've already created based in the contents of the current master.

Finally, to illustrate, the structure of both repositories looks like this:

site-layout (ou site-old)
|
+--- master

And how I would like to organize:

site-layout
|
+---master ("transferir" o conteúdo daqui pra bootstrapv4, e depois passar pra cá o conteúdo da bootstrapv3 (ou site-old))
+--- bootstrapv3 (com o conteudo vindo da antiga site-old)
+--- bootstrapv4 (com o conteúdo vindo da master do site-layout)

Thank you in advance!

    
asked by anonymous 13.02.2016 / 00:02

2 answers

2

If the change between what you have in one repository to another is completely different it does not make sense to keep the same.

If the update from bootstrap v3 to v4 is partial, it makes sense to keep the same repository. In that case I think that creating a branch and copying and pasting the files and deleting the ones that will no longer be used is the easiest way.

//site-old
git checkout master
git checkout -b bootstrapv3
git checkout master
git checkout -b bootstrapv4
//Copie e cole todos os arquivos do repositório site-layout que são diferentes.
git add -A
git commit -am "Adição inicial de bootstrapV4"
git push origin //para criar as branches no repositório remote.

Now you can work on both versions independently.

In this case you will have two masters and the master branch will no longer be used or will be used to replicate one of the two versions only.

NOTE: The master branch is only a standard used in the initial generation of git repositories. But git itself has no preference for any branch. So having a main branch that is not the master or having more than one main branch for different versions of the code is not wrong.

    
13.02.2016 / 01:54
1

To "transfer" the branches just rename. To import another repository as a branch, add the remote repository, checkout , and delete the remote:

# renomeia master (atual) para bootstrapv4
git branch -m bootstrapv4

# adicionar repositório remoto e importar como ramificação
git remote add site-old [email protected]:seu-usuario/site-old.git
git remote update site-old
git checkout -b bootstrapv3 site-old/master
git remote remove site-old

As I indicated in the question comment, it would be better if your project does not have the master branch, set the main branch in github.

    
15.02.2016 / 12:12