NoIdeaHowToFixThis
NoIdeaHowToFixThis

Reputation: 4564

git: subdirectory treated as a repo on its own

I have cloned a template project. I have then tore it apart, to make it my own project. Now, git believe that a subdirectory is a branch of the original template project and even when I run git add . -A it does treat it as it was a repository.

When I was getting in the sub, the powershell was indicating that I was getting in a new repo. I executed rm -rf .git in the subdirectory.

Now however, git status says that the branch is up to date but in the master what I have is just an empty directory, while in origin I have all my code.

I tried this with no success.

Upvotes: 0

Views: 764

Answers (3)

Vikash
Vikash

Reputation: 1

  1. Go to the subdirectory (let's say subDir) parent from where it is treated as it own repo.
  2. Now, You're in main git repo
  3. Change the name of that subdirectory (let's say subDir1).
  4. git pull origin <your branch> (it will pull changes from remote)
  5. Now you'll see that subDir and its name changed directory subDir1.
  6. Remove subDir1

Now, subDir and it's content will be part of your main repo.

Upvotes: 0

NoIdeaHowToFixThis
NoIdeaHowToFixThis

Reputation: 4564

No trick did the job. I have just had to delete the repository and start from scratch. Ugly, but got the job done.

Upvotes: 0

Vishnu Atrai
Vishnu Atrai

Reputation: 2368

Your subdirectory is a submodule, so you should use git submodule instructions, as below -

git clone <main app>
cd main_app
git submodule init
git submodule update 

Upvotes: 1

Related Questions