2

I have two files, say FrontEnd and BackEnd in two separate git repos.

I want to combine them into one repository, and copy-pasted them into a brand new repo.

I get this error:

hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint: 
hint:   git submodule add <url> BackEnd
hint: 
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint: 
hint:   git rm --cached BackEnd
hint: 
hint: See "git help submodule" for more information.

And the BackEnd file does not upload.

  1. How can I Upload just as it is (losing all the previous changes)
  2. What are the pros and cons vs using the submodule?
Hugo y
  • 1,421
  • 10
  • 20
haeli05
  • 21
  • 1
  • 3
  • 2
    If you delete the `.git` file in each repository it will no longer be a Git repository and git will treat them as normal files/directories. This will of course lose the history associated with either of those repositories. – larsks Apr 05 '19 at 19:26
  • Possible duplicate of [Need a subdirectory not a submodule](https://stackoverflow.com/questions/33874840/need-a-subdirectory-not-a-submodule) – phd Apr 05 '19 at 19:40
  • https://stackoverflow.com/search?q=%5Bgit%5D+add+subdirectory+not+submodule – phd Apr 05 '19 at 19:40

2 Answers2

0

How can I Upload just as it is (losing all the previous changes)

use a copy command to create a subdirectory. get rid of .git

What are the pros and cons vs using the submodule?

submodules encapsulate multiple git directories under one roof, keeping track of all of them. Git provides multiple functions and qualifiers to work on multiple submodules. You can keep history of the backend this way. However with many submodules it can be problematic to use these features. There are alternatives like 'subtree' or 'subrepo'.

Serge
  • 11,616
  • 3
  • 18
  • 28
0

Problem: You've moved a directory, B into an outer directory, A. Both repos are git modules so you get the error.

Solution:

In A, type:

git rm -r --cached B
git push
git add B
Jared Wilber
  • 6,038
  • 1
  • 32
  • 35