Git change the repo path of a subfolder

311 views Asked by At

I've got a git structure like the following:

/web_app
-- /static
-- /templates
-- app.py

Having this, when i push to my repo, its pushed following exactly that folder structure, but what I want in the repo is this structure:

/web_app
--  /web
    -- /static
    -- /template
-- app.py

So what I want to do is somehow, from my folder in my pc push the folders /static and /templates into /web/ in repo, and when pulling or clonning, keep the original folder structure.

I've been searching trough docs for submodules and subtrees but either I didn't understand well how they work or they don't satisfy my necessities.

So, Is there any way to accomplish this?

Thanks in advance!

2

There are 2 answers

1
M. K. Hunter On BEST ANSWER

My first recommendation is to download the git cheat sheet and keep it handy on your desktop.

The command to accomplish what you want to do is git mv <source> <destination>. in the shell. The documentation for the command states that it will work on directories.

In your case, this means, from the /web_app directory, you should make your "web" directory:

md web

Then you should move your directories

git mv ./static ./web/static
git mv ./template ./web/template
0
Aitor Martin On

What I finnally did was the following:

I created a new Repo, and with git submodule modularized /web.

It solves my problem, but for real problem I posted, check M. K. Hunter option